整洁的大表
作为将 "tidyverse" 与 "bigmemory" 套件结合使用的最后一个练习,您将再次使用 tidyr 和 ggplot2 包来绘制随时间变化的 Borrower Income 比率。
本练习是课程的一部分
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)) +
___