R/US_stateConversion.R
US_stateConversion.Rd
Converts a vector of US state names or codes from one system to
another returning NA
where no match is found.
US_stateCodeToName(stateCode = NULL)
US_stateCodeToFIPS(stateCode = NULL)
US_stateFIPSToName(stateFIPS = NULL)
US_stateFIPSToCode(stateFIPS = NULL)
US_stateNameToCode(stateName = NULL)
US_stateNameToFIPS(stateName = NULL)
Vector of ISO 3166-2 alpha-2 codes.
Vector of two-digit FIPS codes.
Vector of English language state names.
A vector of US state names or codes.
library(MazamaSpatialUtils)
US_stateNameToCode("Washington")
#> [1] "WA"
US_stateNameToFIPS("Washington")
#> [1] "53"
postalCodes <- sample(US_stateCodes$stateCode, 30)
data.frame(
name = US_stateCodeToName(postalCodes),
code = postalCodes,
FIPS = US_stateCodeToFIPS(postalCodes)
)
#> name code FIPS
#> 1 North Dakota ND 38
#> 2 Kentucky KY 21
#> 3 Idaho ID 16
#> 4 Kansas KS 20
#> 5 Colorado CO 08
#> 6 West Virginia WV 54
#> 7 Rhode Island RI 44
#> 8 Pennsylvania PA 42
#> 9 Montana MT 30
#> 10 Illinois IL 17
#> 11 Nevada NV 32
#> 12 North Carolina NC 37
#> 13 Delaware DE 10
#> 14 Alaska AK 02
#> 15 South Dakota SD 46
#> 16 Georgia GA 13
#> 17 Maryland MD 24
#> 18 Massachusetts MA 25
#> 19 Tennessee TN 47
#> 20 Michigan MI 26
#> 21 Indiana IN 18
#> 22 New Mexico NM 35
#> 23 Arkansas AR 05
#> 24 Puerto Rico PR 72
#> 25 Hawaii HI 15
#> 26 Missouri MO 29
#> 27 Alabama AL 01
#> 28 Utah UT 49
#> 29 Arizona AZ 04
#> 30 Louisiana LA 22