計算郡女性所佔百分比
這個資料集包含各郡男性與女性的總人數(不是百分比)。你可以搭配 population 變數,計算每個郡中男性(或女性)所佔的比例。
在本練習中,你要自行選取相關欄位。
本練習屬於課程
使用 dplyr 進行資料操作
練習說明
- 選取欄位
state、county、population、men和women。 - 新增一個名為
proportion_women的變數,內容為該郡人口中女性所佔的比例。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
counties_selected <- counties %>%
# Select the columns state, county, population, men, and women
___
counties_selected %>%
# Calculate proportion_women as the fraction of the population made up of women
___