Learn R Programming

cdlTools (version 0.15)

fips: FIPS code conversion function.

Description

fips converts U.S. state names and abbreviations to and from FIPS codes.

Usage

fips(x, to = "FIPS")

Value

The output type specified by the "to" argument. If no match can be made, the program returns NA.

Arguments

x

A vector, data frame or matrix of character strings or numeric FIPS codes. Character input can be the two-letter postal abbreviation, the full name of a state, or a FIPS code in character format. The string is case insensitive. FIPS codes are the only numeric input supported.

to

A character string of output type: "FIPS" will return a numeric fips code. "Abbreviation" will return a two letter state abbreviation. "Name" will return the full state name with spaces. The default output is a numeric FIPS code.

Author

Jonathan Lisic, jlisic@gmail.com

Details

The Federal Information Processing Standard (FIPS) provides a set of standard numeric codes for refering to U.S. states. This function converts between FIPS codes, state two letter abbreviations, and full state names.

Examples

Run this code
fips("ia")
fips('northcarolina', to='Abbreviation')
fips('North Carolina')
fips(44,to='Name')

Run the code above in your browser using DataLab