開始使用免費開始

使用因子視覺化文字計數

我已經幫你加入了其他自訂停用詞(包含各家航空公司的名稱),並把資料整理好了。現在你要建立更好的視覺化,並將文字依出現次數由大到小排序後繪圖。

本練習屬於課程

R 文字分析入門

檢視課程

練習說明

  • 只保留在 non_complaints 中出現超過 100 次的詞彙。
  • word 欄位重新設為依照文字計數排序的因子。
  • 使用新的文字欄(型別為因子)建立長條圖。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

word_counts <- tidy_twitter %>% 
  filter(complaint_label == "Non-Complaint") %>% 
  count(word) %>% 
  # Keep terms that occur more than 100 times
  ___(___) %>% 
  # Reorder word as an ordered factor by word counts
  ___(word2 = ___(___, ___))

# Plot the new word column with type factor
___(___, aes(___, ___)) +
  ___() +
  ___() +
  ggtitle("Non-Complaint Word Counts")
編輯並執行程式碼