開始使用免費開始

使用 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
  ___
編輯並執行程式碼