【发布时间】:2020-06-15 21:11:53
【问题描述】:
我尝试从这些命令中创建一个取消列表:
library(quanteda)
library(tidyr)
df <- data.frame(id = c(1,2), text = c("I am loving it", "I am hating it but I go, and I teach"), stringsAsFactors = FALSE)
myDfm <- df$text %>%
tokens(remove_punct = TRUE, remove_numbers = TRUE, remove_symbols = TRUE) %>%
tokens_remove(pattern = c(stopwords(source = "smart")))
data.frame(id = c(1,2), text = c("loving", "hating teach")
这是预期输出的示例:
data.frame(id = 1:length(myDfm),text = unlist(myDfm))
id text
1 1 loving
2 2 hating teach
错误:
data.frame(id = 1:length(myDfm), text = unlist(myDfm)) 中的错误:
参数意味着不同的行数:2, 3
【问题讨论】:
-
data.frame(id = seq_along(myDfm), text = sapply(myDfm, paste, collapse = " "))
标签: r