使用 relocate
正如您在视频中学到的,relocate() 动词可让您将列相对于其他列或相对于在 tibble 中的整体位置进行移动。
您拿到的 counties_selected tibble 已包含分析人口密度所需的列,但当前顺序不便于阅读。请运用您新掌握的技巧把它们调整到合适的位置!
本练习是课程的一部分
使用 dplyr 进行数据处理
练习说明
- 将
density列移动到 tibble 的末尾。 - 将
population列移动到land_area列之前。
交互式实操练习
通过完成这段示例代码来试试这个练习。
counties_selected %>%
# Move the density column to the end
___
# Move the population column to before land_area
___