練習分組彙總
你也可以把 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`)