stateToCode {MazamaSpatialUtils}R Documentation

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

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.

Value

A vector of ISO 3166-2 codes or NA.

See Also

convertNaturalEarthAdm1

Examples

## Not run: 
stateToCode("Washington")
stateToCode("Barcelona")
stateToCode("Shandong")

## End(Not run)

[Package MazamaSpatialUtils version 0.8.6 Index]