lookup_code: Look up state and county codes

View source: R/helpers.R

lookup_codeR Documentation

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 documentation built on Sept. 22, 2023, 5:13 p.m.