开始使用免费开始使用

使用因子可视化词频

我已为您添加了一些自定义停用词(包括航空公司名称),并整理好了数据。现在请创建一个更好的可视化,将单词按词频降序排列后绘图。

本练习是课程的一部分

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")
编辑并运行代码