as_fips_code {wru} | R Documentation |
Convert between state names, postal abbreviations, and FIPS codes
Description
Convert between state names, postal abbreviations, and FIPS codes
Usage
as_fips_code(x)
as_state_abbreviation(x)
Arguments
x |
A numeric or character vector of state names, postal abbreviations, or FIPS codes. Matches for state names and abbreviations are not case sensitive. FIPS codes may be matched from numeric or character vectors, with or without leading zeroes. |
Value
as_state_fips_code()
-
A character vector of two-digit FIPS codes. One-digit FIPS codes are prefixed with a leading zero, e.g.,
"06"
for California. as_state_abbreviation()
-
A character vector of two-letter postal abbreviations, e.g.,
"CA"
for California.
Examples
as_fips_code("california")
as_state_abbreviation("california")
# Character vector matches ignore case
as_fips_code(c("DC", "Md", "va"))
as_state_abbreviation(c("district of columbia", "Maryland", "VIRGINIA"))
# Note that `3` and `7` are standardized to `NA`,
# because no state is assigned those FIPS codes
as_fips_code(1:10)
as_state_abbreviation(1:10)
# You can even mix methods in the same vector
as_fips_code(c("utah", "NM", 8, "04"))
as_state_abbreviation(c("utah", "NM", 8, "04"))
[Package wru version 3.0.3 Index]