開始使用免費開始

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
___
編輯並執行程式碼