一些摘要統計
使用 dplyr 的 group_by() 和 summarize(),為兩個年份計算摘要統計。
本練習屬於課程
在 Tidyverse 中以資料溝通
練習說明
- 先用
str()檢視ilo_data資料集的結構。 - 接著使用
group_by()依年份對資料分組。 - 然後使用
summarize()分別計算變數hourly_compensation與working_hours的平均值。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Examine the structure of ilo_data
___(ilo_data)
# Group and summarize the data
ilo_data %>%
group_by(___) %>%
___(mean_hourly_compensation = ___(___),
mean_working_hours = ___(___))