Borrower Income Ratio(借款人收入比)
Borrower income ratio 是指借款人(或多位借款人)的年收入,除以該申報年度該地區的家庭收入中位數。這個比率用來判定借款人的收入是否符合以收入為基礎的住房目標。
在資料集 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