NRC の感情を可視化する
可視化は、単なるカウントだけでは見えないデータのパターンを把握するのに役立ちます。ここでは、nrc 辞書の感情を可視化してみましょう。tidyverse と tidytext パッケージはすでに読み込んであります。
この演習はコースの一部です
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"
___(
___ = ___,
___ = ___,
___ = ___
)