Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lookup_code

Look up state and county codes


Description

Function to look up the FIPS codes for states and optionally counties you'd l ike to load data for. As the package functions require the codes to return the data correctly, this function makes it easy to find the codes that you need.

Usage

lookup_code(state, county = NULL)

Arguments

state

String representing the state you'd like to look up. Accepts state names (spelled correctly), e.g. "Texas", or postal codes, e.g. "TX". Can be lower-case.

county

The name of the county you'll like to search for. T he state that the county is located in must be supplied for this to work, as there are multiple counties with the same names across states. Can be lower-case.

Value

character string with an explanation of state/county FIPS codes

Examples

## Not run: 
lookup_code("me")
## [1] "The code for Maine is '23'."

lookup_code("Maine")
## [1] "The code for Maine is '23'."

lookup_code("23")
## [1] "The code for Maine is '23'."

lookup_code(23)
## [1] "The code for Maine is '23'."

lookup_code("me", "york")
## [1] "The code for Maine is '23' and the code for York County is '031'."

lookup_code("Maine", "York County")
## [1] "The code for Maine is '23' and the code for York County is '031'."

## End(Not run)

tigris

Load Census TIGER/Line Shapefiles

v1.0
MIT + file LICENSE
Authors
Kyle Walker [aut, cre], Bob Rudis [ctb]
Initial release
2020-07-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.