依產品計數並重新排序
tidy_twitter 已完成斷詞,且已移除停用字(包含自訂停用字)。你想要視覺化比較抱怨與非抱怨在字詞計數上的差異。
本練習屬於課程
R 文字分析入門
練習說明
- 依是否為抱怨來計算字詞次數。
- 依是否為抱怨,各自保留前 20 個字詞。
- 在依計數將字詞重設為因子並重新排序之前,先取消分組。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
word_counts <- tidy_twitter %>%
# Count words by whether or not its a complaint
___(___, ___) %>%
# Group by whether or not its a complaint
group_by(___) %>%
# Keep the top 20 words
___(___, ___) %>%
# Ungroup before reordering word as a factor by the count
___() %>%
___(word2 = ___(___, ___))