如何输入美国所有 50 个州而不必在 R 中全部输入?
How to input all 50 states in the United States without having to type them all in R?
我正在尝试删除数据集中具有 U.S 州名称的行。我希望有一种方法可以在不输入所有 50 个代码的情况下输入代码。
下面我分享了大图以及我希望在何处输入这些状态。
cshealthpredictors %>%
filter(!region %in% c("Alabama", "Arkansas" ,"Missouri","Texas","Georgia"))
正如@Ritchie 在评论中提到的那样,在 base R 中有一个内置的。
state.name
#> [1] "Alabama" "Alaska" "Arizona" "Arkansas"
#> [5] "California" "Colorado" "Connecticut" "Delaware"
#> [9] "Florida" "Georgia" "Hawaii" "Idaho"
#> [13] "Illinois" "Indiana" "Iowa" "Kansas"
#> [17] "Kentucky" "Louisiana" "Maine" "Maryland"
#> [21] "Massachusetts" "Michigan" "Minnesota" "Mississippi"
#> [25] "Missouri" "Montana" "Nebraska" "Nevada"
#> [29] "New Hampshire" "New Jersey" "New Mexico" "New York"
#> [33] "North Carolina" "North Dakota" "Ohio" "Oklahoma"
#> [37] "Oregon" "Pennsylvania" "Rhode Island" "South Carolina"
#> [41] "South Dakota" "Tennessee" "Texas" "Utah"
#> [45] "Vermont" "Virginia" "Washington" "West Virginia"
#> [49] "Wisconsin" "Wyoming"
由 reprex package (v2.0.1)
创建于 2022-02-10
我正在尝试删除数据集中具有 U.S 州名称的行。我希望有一种方法可以在不输入所有 50 个代码的情况下输入代码。 下面我分享了大图以及我希望在何处输入这些状态。
cshealthpredictors %>%
filter(!region %in% c("Alabama", "Arkansas" ,"Missouri","Texas","Georgia"))
正如@Ritchie 在评论中提到的那样,在 base R 中有一个内置的。
state.name
#> [1] "Alabama" "Alaska" "Arizona" "Arkansas"
#> [5] "California" "Colorado" "Connecticut" "Delaware"
#> [9] "Florida" "Georgia" "Hawaii" "Idaho"
#> [13] "Illinois" "Indiana" "Iowa" "Kansas"
#> [17] "Kentucky" "Louisiana" "Maine" "Maryland"
#> [21] "Massachusetts" "Michigan" "Minnesota" "Mississippi"
#> [25] "Missouri" "Montana" "Nebraska" "Nevada"
#> [29] "New Hampshire" "New Jersey" "New Mexico" "New York"
#> [33] "North Carolina" "North Dakota" "Ohio" "Oklahoma"
#> [37] "Oregon" "Pennsylvania" "Rhode Island" "South Carolina"
#> [41] "South Dakota" "Tennessee" "Texas" "Utah"
#> [45] "Vermont" "Virginia" "Washington" "West Virginia"
#> [49] "Wisconsin" "Wyoming"
由 reprex package (v2.0.1)
创建于 2022-02-10