開始使用免費開始

展開資料框

你現在已經把每個模型整理後存到 tidied 欄位。你想把這些整理後的結果合併成一個大型資料框,就像先前合併美國與英國的整理模型一樣。回想一下,tidyr 中的 unnest() 可以達成這件事。

本練習屬於課程

案例研究:R 中的探索性資料分析

檢視課程

練習說明

  • 新增一個 unnest() 步驟,將存於 tidied 欄位的整理模型展開。把結果儲存為 country_coefficients
  • 在主控台印出 country_coefficients 物件。

動手互動練習

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

# Add one more step that unnests the tidied column
___ <- by_year_country %>%
  nest(-country) %>%
  mutate(model = map(data, ~ lm(percent_yes ~ year, data = .)),
         tidied = map(model, tidy))


# Print the resulting country_coefficients variable
編輯並執行程式碼