開始使用免費開始

視覺化 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"
  ___(
    ___ = ___,
    ___ = ___,
    ___ = ___
  )
編輯並執行程式碼