mutate、filter 與 arrange
在這個練習中,你會把本章學到的內容(select()、mutate()、filter() 和 arrange())整合起來,找出男性比例最高的郡(county)。
本練習屬於課程
使用 dplyr 進行資料操作
練習說明
- 使用「單一動詞」新增一個
proportion_men欄位,內容為男性人口所占比例,並同時保留state、county和population欄位。 - 篩選人口至少一萬(
10000)的郡。 - 依男性比例由高到低排列郡。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
counties %>%
# Keep state, county and add proportion_men
___
# Filter for population of at least 10,000
___
# Arrange proportion of men in descending order
___