fips: Retrieve FIPS code for either a US state or county
Description
Each US state and county has a unique FIPS
(Federal Information Processing Standards) code. Use
this function to obtain the FIPS code for a state or
county.
Usage
fips(state, county = c())
Arguments
state
The state(s) for which to obtain a FIPS code(s).
Can be entered as either a state abbreviation or full name (case-insensitive).
`state` can be entered as either a single state or a vector of states.
If `state` is a vector, `county` must be omitted.
county
The county for which to obtain a FIPS code.
Can be entered with or without "county" (case-insensitive).
Value
The FIPS code(s) of given state or county.
If only states are entered, a vector of length equal to the number of states
is returned. If any states are not found or are invalid, `NA` is returned in their place.
If a state and county are entered, a single value with the FIPS code
for the given county is returned. If the county is invalid for the given state,
an error is thrown.
Details
State and county FIPS (Federal Information Processing Standards) are
two and five digit codes, respectively. They uniquely identify all states and
counties within the United States. The first two digits of the five digit county
codes correspond to the state that the county belongs to. FIPS codes also exist
for US territories and minor outlying islands, though this package only provides
information for the 50 US states (and their associated counties and
census designated areas).
# NOT RUN {fips("NJ")
fips("California")
fips(c("AK", "CA", "UT"))
fips("CA", county = "orange")
fips(state = "AL", county = "autauga")
fips(state = "Alabama", county = "Autauga County")
# }