使用 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
___