分组汇总练习
我们也可以将 pivot_wider() 与分组汇总的输出配合使用。
本练习是课程的一部分
R 文本分析入门
练习说明
- 将
tidy_twitter与 AFINN 情感词典进行连接。 - 同时按投诉标签以及用户是否已验证进行分组。
- 汇总数据,创建新列
aggregate_value,其值为value的总和。 - 展开
complaint_label与aggregate_value两列。
交互式实操练习
通过完成这段示例代码来试试这个练习。
tidy_twitter %>%
# Append the afinn sentiment dictionary
___(___) %>%
# Group by both complaint label and whether or not the user is verified
___(___) %>%
# Summarize the data with an aggregate_value = sum(value)
___(___) %>%
# Spread the complaint_label and aggregate_value columns
___(___) %>%
mutate(overall_sentiment = Complaint + `Non-Complaint`)