Skip to contents

Retrieve states or counties using FIPS codes

Usage

fips_info(fips, sortAndRemoveDuplicates = FALSE)

# S3 method for numeric
fips_info(fips, sortAndRemoveDuplicates = FALSE)

# S3 method for character
fips_info(fips, sortAndRemoveDuplicates = FALSE)

Arguments

fips

A one to five digit, either numeric or character, vector of FIPS codes for which to look up states or counties. States have a two digit FIPS code and counties have a five digit FIPS code (where the first 2 numbers pertain to the state).

sortAndRemoveDuplicates

Whether or not to sort the output and remove duplicates. By default, the output will be returned in the order of the values provided to the fips parameter. Set this parameter to TRUE to return the output sorted by FIPS with a single instance of each FIPS.

Value

A data frame with the states or counties and the associated FIPS codes.

If fips is omitted, the data frame containing all available states is returned.

Examples

fips_info(2)
#>   abbr fips   full
#> 1   AK   02 Alaska
fips_info("2")
#>   abbr fips   full
#> 1   AK   02 Alaska
fips_info(c("02", "03", "04"))
#> Warning: FIPS code(s) 03 not found
#>   abbr fips    full
#> 1   AK   02  Alaska
#> 2   AZ   04 Arizona

fips_info(2016)
#>     full abbr                     county  fips
#> 1 Alaska   AK Aleutians West Census Area 02016
fips_info(c("02016", "02017"), sortAndRemoveDuplicates = TRUE)
#> Warning: FIPS code(s) 02017 not found
#>     full abbr                     county  fips
#> 1 Alaska   AK Aleutians West Census Area 02016