开始使用免费开始使用

mutate、filter 和 arrange

在本练习中,您将把本章学到的所有内容(select()mutate()filter()arrange())综合起来,找出男性比例最高的县。

本练习是课程的一部分

使用 dplyr 进行数据处理

查看课程

练习说明

  • 使用一个「单一动词」添加 proportion_men 列,其中包含男性人口所占比例,并同时保留 statecountypopulation 列。
  • 仅保留人口至少一万(10000)的县。
  • 按男性比例的降序排列各县。

交互式实操练习

通过完成这段示例代码来试试这个练习。

counties %>%
  # Keep state, county and add proportion_men
  ___
  # Filter for population of at least 10,000
  ___
  # Arrange proportion of men in descending order 
  ___
编辑并运行代码