开始使用免费开始使用

可视化 NRC 的情感分类

我们已经看到,可视化比单纯计数更能帮助我们把握数据中的模式。现在来可视化 nrc 词典中的情感。已为您预先加载 tidyversetidytext 包。

本练习是课程的一部分

R 文本分析入门

查看课程

练习说明

  • 提取 nrc 词典,统计各类情感并按计数重排,生成新的因子列 sentiment2
  • 使用新的情感因子列来可视化 sentiment_counts
  • 将标题改为 "Sentiment Counts in NRC",x 轴为 "Sentiment",y 轴为 "Counts"。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Pull in the nrc dictionary, count the sentiments and reorder them by count
sentiment_counts <- ___(___) %>% 
  ___(___) %>% 
  ___(sentiment2 = ___(___, ___))

# Visualize sentiment_counts using the new sentiment factor column
___(___, aes(___, ___)) +
  geom_col() +
  coord_flip() +
  # Change the title to "Sentiment Counts in NRC", x-axis to "Sentiment", and y-axis to "Counts"
  ___(
    ___ = ___,
    ___ = ___,
    ___ = ___
  )
编辑并运行代码