借款人收入比
借款人收入比指借款人(或共同借款人)年度收入与该报告年度当地家庭收入中位数的比值。该比值用于判断借款人收入是否满足基于收入的住房目标。
在数据集 mort 中,缺失值被重编码为 9。在本练习中,我们已将 "borrower_income_ratio" 列中的 9 替换为 NA,这样您就可以为借款人收入比创建一个列联表。
本练习是课程的一部分
R 的可扩展数据处理
练习说明
- 载入
biganalytics和dplyr包。 - 对
mort调用summary(),检查"borrower_income_ratio"现在是否包含NA。 - 使用
bigtable(),按年份创建借款人收入比的表。 - 使用
dplyr的mutate()添加新列BIR。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Load biganalytics and dplyr packages
___
___
# Call summary on mort
___
bir_df_wide <- ___(mort, c(___, "year")) %>%
# Turn it into a data.frame
as.data.frame() %>%
# Create a new column called BIR with the corresponding table categories
___(BIR = c(">=0,<=50%", ">50, <=80%", ">80%"))
bir_df_wide