開始使用免費開始

Combine

你現在已經知道所有年份中,都市與鄉村地區的女性借款比例。不過,結果目前存在於一個 list 裡。若你想要計算摘要統計或視覺化結果,把這個 list 轉成矩陣或資料框有時會更方便。在這個練習中,你會把結果合併成一個矩陣。

本練習屬於課程

R 的可擴展資料處理

檢視課程

練習說明

all_years(前一個練習的物件)已經在你的工作空間中。

  • all_years 呼叫 Reduce(),將前一個練習的結果合併起來。這裡要套用的函式是 rbind(row bind 的縮寫)。
  • 使用 dimnames() 函式替這個矩陣 prop_female 加上列名與欄名。
    • 列名是 list all_yearsnames()

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Collect the results as rows in a matrix
prop_female <- ___(___, ___)

# Rename the row and column names
___(prop_female) <- list(___, c("prop_female_urban", "prop_femal_rural"))

# View the matrix
prop_female
編輯並執行程式碼