find_svi_x()
is like a wrapper for
get_census_data()
and get_svi_x()
that retrieves
census data and produces SVI for a customized geographic level consisted of
a Census geography. The census data is retrieved at the Census geographic
level, and estimate counts are summed across the customized geographic
level to calculate SVI. 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()
.
find_svi_x(
year,
geography,
state = NULL,
county = NULL,
key = NULL,
geometry = FALSE,
xwalk
)
A tibble of SVI with rows representing the customized geographic
units (with a column name of GEOID
), and columns indicating variable
names (first two columns containing geographic information). For detailed
description of the variable names (column names), please refer to
CDC/ATSDR
documentation (https://www.atsdr.cdc.gov/placeandhealth/svi/data_documentation_download.html).
A year of interest (available 2012-2022).
The Census geography level of interest (e.g."county", "zcta", "tract").
(Optional) Specify the state of interest. Default state = NULL
or state = 'US'
return nation-level data.
(Optional) Specify the county 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. To set up, use
tidycensus::census_api_key("YOUR KEY GOES HERE")
, or include it as an
argument.
Default as FALSE
for retrieving census data without spatial
information. Set as TRUE
for retrieving census data with an additional
geometry
column containing simple feature geometry.
A crosswalk (relationship table) between the Census geographic
level and the customized geographic level of interest. A crosswalk between
US counties and commuting zones cty_cz_2020_xwalk
is included as an
example, and please set the column names of the crosswalk as follows:
Identifiers for the Census geographic level. Must contain values from GEOID
column in data
, and be in a compatible data type (character).
Identifiers (characters or numeric values) for the customized geographic level that is larger geographic than the Census geographic level. The Census geographic level should be nested in the customized geographic level.
An optional column of the names or description of the customized geographic level.
find_svi()
for retrieving census data and calculating SVI for
multiple year-state pairs at a Census geographic level. get_census_data()
(with exp = TRUE
) and get_svi_x()
for separate functions for data
retrieval and SVI calculation at a customized geographic level.
if (FALSE) { # Sys.getenv("CENSUS_API_KEY") != ""
# Census API key required
find_svi_x(
year = 2020,
geography = "county",
xwalk = cty_cz_2020_xwalk
)
}
Run the code above in your browser using DataLab