ビッグテーブルを整然データに
この演習の締めくくりとして、"bigmemory" スイートと組み合わせて "tidyverse" を使い、tidyr と ggplot2 パッケージで Borrower Income ratio の推移をプロットします。
この演習はコースの一部です
Rで学ぶスケーラブルなデータ処理
演習の手順
tidyrとggplot2パッケージを読み込みます。pivot_longer()関数を使って、年ごとのカウントを縦持ちにまとめます。- x 軸に
Year、y 軸にCountを取り、BIRで色分け・グループ化した折れ線グラフを作成します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# Load the tidyr and ggplot2 packages
library(___)
library(___)
bir_df_wide %>%
# Transform the wide-formatted data.frame into the long format
___(-BIR, names_to = "Year", values_to = "Count") %>%
# Use ggplot to create a line plot
ggplot(aes(x = ___, y = ___, group = BIR, color = BIR)) +
___