cens_geo {easycensus}R Documentation

Construct a Geography Specification for Census Data

Description

Currently used mostly internally. Builds a Census API-formatted specification of which geographies to download data for. State and county names (or postal abbreviations) are partially matched to existing tables, for ease of use. Other geographies should be specified with Census GEOIDs. The usgazeteer package, available with remotes::install_github("bhaskarvk/usgazetteer"), may be useful in finding GEOIDs for other geographies. Consult the "geography" sections of each API at https://www.census.gov/data/developers/data-sets.html for information on which geographic specifiers may be provided in combination with others.

Usage

cens_geo(geo = NULL, ..., check = TRUE, api = "acs/acs5", year = 2019)

Arguments

geo

The geographic level to return. One of the machine-readable or human-readable names listed in the "Details" section. Will return all matching geographies of this level, as filtered by the further arguments to .... For example, setting geo="tract" is equivalent to setting tract="all".

...

Geographies to return, as supported by the Census API. Order matters here—the first argument will be the geographic level to return (i.e., it corresponds to the geo argument) and additional arguments will filter the results. Use "all", "*", NA, or TRUE to return all units of a particular geography. See the examples for details.

check

If TRUE, validate the provided geographies against the available geographies from the relevant Census API. Requires the api and year arguments to be specified.

api

A Census API programmatic name such as "acs/acs5".

year

The year for the data

Details

Supported geography arguments:

Value

A list with two elements, region and regionin, which together specify a valid Census API geography argument.

Examples

cens_geo(state="WA")
cens_geo("county", state="WA") # equivalent to `cens_geo(county="all", state="WA")`
cens_geo(county="King", state="Wash")
cens_geo(zcta="02138", check=FALSE)
cens_geo(zcta=NA, state="WA", check=FALSE)
cens_geo("zcta", state="WA", check=FALSE)
cens_geo(cd="09", state="WA", check=FALSE)
cens_geo("county_part", state="WA", cd="09", check=FALSE)


[Package easycensus version 1.1.1 Index]