同時使用 summarize、slice_max 與 count
在本章中,你學會了 6 個與彙整相關的 dplyr 動詞:count()、group_by()、summarize()、ungroup()、slice_max(),以及 slice_min()。在這個練習中,你會把它們組合起來回答一個問題:
「有多少州在都會區居住的人口多於非都會區?」
請記得,metro 欄位只有兩種值:"Metro"(高密度城市區域)或 "Nonmetro"(近郊與鄉村區域)。
counties_selected <- counties %>%
select(state, metro, population)
本練習屬於課程
使用 dplyr 進行資料操作
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
counties_selected %>%
# Find the total population for each combination of state and metro
___