最初のプロットを作成する
これまでのレッスンでは、可視化に向けてデータを整形・クレンジングしました。いよいよ FiveThirtyEight のグラフを再現していきます。まずは最初のプロットから始めましょう。前の章で作成したデータセット rude_behaviors は読み込まれています。
この演習はコースの一部です
tidyverse で学ぶカテゴリ型データ
演習の手順
response_varをperc_rudeの値で並べ替きますperc_rudeに対するresponse_varの棒グラフを作成し、initial_plotとして保存します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
initial_plot <- rude_behaviors %>%
# Reorder response_var by perc_rude
mutate(response_var = ___(response_var, perc_rude)) %>%
# Make a bar plot of perc_rude by response_var
ggplot(aes(x = ___, y = ___)) +
geom_bar(stat = "identity")
# View your plot
initial_plot