View source: R/get.county.info.R
get.county.info | R Documentation |
Function that reports some or all of a table of data about queried (or all) US Counties (and county equivalents) for 1 or more counties. Query terms can be 5-digit FIPS, or countyname, statename or just statename or just 2-letter state abbrev. Montgomery, MD will not work. Montgomery County, Maryland will work. UPDATED 6/2022 TO ACS 2020 COUNTY LIST (this relies on proxistat::countiesall)
Requested fields can include any of these: ST, countyname, FIPS.COUNTY, statename, fullname
get.county.info(query, fields = "all")
query |
Vector of search terms. Can be county's 5-digit FIPS code(s) (as numbers or strings with numbers), and also could be 'countyname, statename' (fullname, exactly matching formats in countiesall$fullname, but case insensitive). |
fields |
Character string optional defaults to 'all' but can specify 'countyname' 'ST' and/or 'FIPS.COUNTY' |
Converted basic data to data, so now can also say data(counties, package="proxistat")
or x <- countiesall via lazy loading.
Also see various packages like acs package or help( package="choroplethr")
Also see:
https://www.census.gov/geographies/reference-files/time-series/geo/gazetteer-files.html
Note this other possible list of abbreviations (not used) lacks US, PR, DC:
require(datasets); state.abb
Note another possible list of States, abbrev, FIPS
which has island areas but not US total and not leading zeroes on FIPS:
require(acs)
print(fips.state)
Returns a data.frame or vector of results depending on fields selected. Returns a data.frame (if query has 2+ elements), 'QUERY' as first column, and then all or specified fields of information, covering matching counties, or NA if certain problems arise. If no query term, or fields not specified, then all information fields are returned: QUERY, ST, countyname, FIPS.COUNTY, statename, fullname
testdata <- c('01001', 1001, '1001', "Montgomery County, Maryland", "Montgomery County, MD",
'montgomery county, maryland', "Montgomery County MD", "MontgomeryCountyMD",
"Montgomery County", "NY")
testonlystates <- c('NY', 'NJ')
get.county.info(testdata)
get.county.info(testonlystates)
get.county.info(c('New Jersey'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.