Split
為了計算所有年度的比例,你會使用前一題定義的函式 female_residence_prop(),以及另外三個函式:
split():依年份「分割」mort資料Map():將female_residence_prop()「套用」到split()回傳的每個子集Reduce():將Map()取得的結果「彙整」起來
在本練習中,你會依年份「分割」mort 資料。
本練習屬於課程
R 的可擴展資料處理
練習說明
- 依
"year"欄位分組,將房貸資料的列索引做 split,並把結果指定給spl。 - 對
spl呼叫str()檢視結果。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Split the row numbers of the mortage data by year
spl <- ___(1:nrow(___), mort[, ___])
# Call str on spl
___