ファセットで単語数を可視化する
前の演習で作成した word_counts が読み込まれています。苦情ツイートと非苦情ツイートを別々のファセットに分けて、Twitter データの単語数を可視化してみましょう。
この演習はコースの一部です
Rで始めるテキスト分析
演習の手順
- 苦情かどうかに応じて色の美的属性を設定します。
- 棒グラフの凡例は表示しません。
- ツイートが苦情かどうかでファセット分けし、y 軸は自由尺度にします。
- 座標を反転し、タイトル「Twitter Word Counts」を追加します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Include a color aesthetic tied to whether or not its a complaint
ggplot(word_counts, aes(x = word2, y = n, ___)) +
# Don't include the lengend for the column plot
geom_col(___) +
# Facet by whether or not its a complaint and make the y-axis free
___(___, scales = ___) +
# Flip the coordinates and add a title: "Twitter Word Counts"
___() +
___(___)