计算县域女性占比
该数据集包含每个县的男性与女性总人数(不是百分比)。您可以结合 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
___