MazamaSpatialUtils (version 0.8.6)

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")

Value

A vector of ISO 3166-2 codes or NA.

Arguments

stateNames

Vector of state names to be converted.

countryCodes

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

dataset

Name of dataset containing state-level identifiers.

Details

For this function to work, you must install and load the "NaturalEarthAdm1" dataset.

See Also

convertNaturalEarthAdm1

Examples

Run this code
if (FALSE) {
stateToCode("Washington")
stateToCode("Barcelona")
stateToCode("Shandong")
}

Run the code above in your browser using DataLab