我有一个拥有大约190,000行的Facebook数据的csv文件。列名如下:
comment_id, status_id, parent_id, comment_message, comment_author, comment_published, comment_likes, Positive, Negative, Sentiment
我想知道哪些comment_author
评论最多(comment_message
#)和Sentiment > 0
。
有人知道如何使用R来应用这个过滤器吗?
如果df
是您的数据框,您可以使用dplyr
包,如下所示:
df %>% group_by(comment_author,sentiment) %>%
dplyr::summarize(total_number_comment=sum(comment_message)) %>%
as.data.frame() %>%
arrange(desc(total_number_comment)) %>%
filter(sentiment>0)
我不明白你真正想用sentiment
变量做什么(例如你需要提供一个例子),但分组部分已完成