Learn R Programming

MazamaSpatialUtils (version 0.8.6)

US_stateConversion: Conversion functions for US state names, codes and FIPS codes.

Description

Converts a vector of US state names or codes from one system to another reuturning NA where no match is found.

Usage

US_stateCodeToName(stateCode = NULL)

US_stateCodeToFIPS(stateCode = NULL)

US_stateFIPSToName(stateFIPS = NULL)

US_stateFIPSToCode(stateFIPS = NULL)

US_stateNameToCode(stateName = NULL)

US_stateNameToFIPS(stateName = NULL)

Value

A vector of US state names or codes.

Arguments

stateCode

Vector of ISO 3166-2 alpha-2 codes.

stateFIPS

Vector of two-digit FIPS codes.

stateName

Vector of English language state names.

Examples

Run this code
library(MazamaSpatialUtils)

US_stateNameToCode("Washington")
US_stateNameToFIPS("Washington")

postalCodes <- sample(US_stateCodes$stateCode, 30)

data.frame(
  name = US_stateCodeToName(postalCodes),
  code = postalCodes,
  FIPS = US_stateCodeToFIPS(postalCodes)
)

Run the code above in your browser using DataLab