This function uses tidycensus::get_acs()
with a pre-defined
list of variables to retrieves ACS data for SVI calculation. Note that a
Census API key is required for this function to work, which can be obtained
at https://api.census.gov/data/key_signup.html and set up using
tidycensus::census_api_key()
.
get_census_data(
year,
geography,
state = NULL,
county = NULL,
key = NULL,
geometry = FALSE,
exp = FALSE,
...
)
A tibble of ACS data with each row represents an enumeration (geographic) unit and each column represents a census variable ("wide" form).
The year of interest (available 2012-2022).
The geography of interest (eg. state, county, zcta, tract)
(Optional) Specify the state of interest. If data for multiple
states are retrieved together, ranking for SVI calculation will be
performed among all states. state = NULL
as default, or state = 'US'
return nation-level data.
(Optional) Specify the county(s) of interest, must be combined with a value supplied to "state".
Your Census API key. Obtain one at
https://api.census.gov/data/key_signup.html. Include it in this argument
or set up your key using tidycensus::census_api_key("YOUR KEY GOES HERE")
.
Default as FALSE
for a regular tibble of census data. If
set as TRUE
, returns a tibble with an additional geometry
column
containing simple feature geometry.
Default as FALSE
for retrieving EP_
(percent estimate)
variables directly from ACS when available (as described in CDC/ADSTR SVI
dictionary (https://www.atsdr.cdc.gov/placeandhealth/svi/data_documentation_download.html)).
If set as TRUE
, uses explicitly defined denominators and retrieves the
ACS data to calculate the EP
variables for easier aggregation in
downstream analysis (e.g. get_svi_x()
).
Other arguments; more details please see tidycensus::get_acs()
if (FALSE) { # Sys.getenv("CENSUS_API_KEY") != ""
# Census API key required
get_census_data(
year = 2018,
geography = "county",
state = "PA"
)
}
Run the code above in your browser using DataLab