เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Combine

You now know the female proportion borrowing for urban and rural areas for all years. However, the result resides in a list. Converting this list to a matrix or data frame may sometimes be convenient in case you want to calculate any summary statistics or visualize the results. In this exercise, you will combine the results into a matrix.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Scalable Data Processing in R

ดูคอร์ส

คำแนะนำการฝึกหัด

all_years from the previous exercise is available in your workspace.

  • Call Reduce() on all_years to combine the results from the previous exercise. The function to apply here is rbind (short for row bind).
  • Use the dimnames() function to add row and column names to this matrix, prop_female.
    • The rownames are the names() of the list all_years.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# 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
แก้ไขและรันโค้ด