【发布时间】:2017-05-08 20:14:25
【问题描述】:
我是 R 的新手,所以这个问题似乎很明显。但是,我没有管理,也没有找到解决方案
当标记是行(实际上是评论)时,如何计算标记中的单词数? 因此,有一个数据集,其中评论(reviewText)与产品 ID(asin)相连
amazonr_tidy_sent = amazonr_tidy_sent%>%unnest_tokens(word, reviewText, token = "lines")
amazonr_tidy_sent = amazonr_tidy_sent %>% anti_join(stop_words)%>%ungroup()
我尝试了以下方式
wordcounts <- amazonr_tidy_sent %>%
group_by(word, asin)%>%
summarize(word = n())
但这不合适。我认为,没有办法计算,因为作为标记的行不能“分离”
非常感谢
【问题讨论】:
-
amazonr_tidy_sent长什么样子? -
两列:“asin”(例如,B000M341QE、B000J3OTO6 等)和“word”。 “word”列是使用
unnest_tokens标记为行的评论 -
你能发帖
dput(head(amazonr_tidy_sent, 10))吗? -
structure(list(asin = "0764005693", reviewText = "the famous author peter neal is on a publicity tour through italy when a mysterious killer begins staging murders after those found in his most recent novel neal must partner with the police and follow a trail ... <truncated> "reviewText"), row.names = 1L, class = "data.frame") -
长度(strsplit(x, sep = " "))?也许使用 group_by 行文本。