用 tidyverse 工具探索變數
載入後,你的 Census 或 ACS 變數資料集可能包含成千上萬筆列。在 RStudio 中,建議使用 View() 函式以互動方式搜尋這些變數。若不在 RStudio,則可以使用 tidyverse 的篩選工具來瀏覽這些資料集。
本練習屬於課程
在 R 中分析美國人口普查資料
練習說明
- 載入
tidyverse套件。 - 使用
str_detect()函式,將v16資料框過濾為資料表B19001中的變數。 - 使用字串
"public transportation"來搜尋與大眾運輸相關的變數。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Load the tidyverse
library(___)
# Filter for table B19001
filter(v16, ___(name, "___"))
# Use public transportation to search for related variables
filter(v16p, ___(label, fixed("___",
ignore_case = TRUE)))