選取欄位
使用 select() 動詞,你可以聚焦在相關的一組變數,來回答關於資料集的有趣問題。冒號(:)很適合一次取得多個欄位。
本練習屬於課程
使用 dplyr 進行資料操作
練習說明
- 使用
glimpse()檢視counties資料表中的所有變數。 - 選取
state、county、population這些欄位,並使用冒號一次選取那五個與產業相關的欄位;在表格中有五個連續的欄位與人們工作的產業有關:professional、service、office、construction和production。 - 依
service遞減排序資料表,以找出哪些郡在服務業工作的比例最高。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Glimpse the counties table
___
counties %>%
# Select state, county, population, and industry-related columns
___
# Arrange service in descending order
___