MazamaSpatialUtils (version 0.6.4)

stateToCode: Convert state names to state codes

Description

Converts a vector of state names to an ISO 3166-2 two character state codes.

Usage

stateToCode(stateNames, countryCodes = NULL,
  dataset = "NaturalEarthAdm1")

Arguments

stateNames

state names to be converted

countryCodes

ISO 3166-2 alpha-2 country codes the state might be found in

dataset

name of dataset containing state-level identifiers

Value

A vector of ISO 3166-2 codes or NA.

Details

For this function to work, you must first run initializeSpatialData() to download, convert and install the necessary spatial data.

See Also

convertNaturalEarthAdm1

Examples

Run this code
# NOT RUN {
stateToCode("Washington")
stateToCode("Barcelona")
stateToCode("Shandong")
# }

Run the code above in your browser using DataCamp Workspace