View source: R/calculate_adi.R
calculate_adi | R Documentation |
Calculate the Area Deprivation Index and Berg Indices (ADI-3) using decennial US census or American Community Survey (ACS) variables.
calculate_adi(data_raw, keep_indicators = FALSE, seed = NA)
data_raw |
A data frame, The columns of his data frame must be named according to the elements of
the The easiest way to obtain data like this is to run
|
keep_indicators |
Logical indicating whether or not to keep the
component indicators of the ADI and ADI-3 as well as the original census
variables used to calculate them. Defaults to See |
seed |
Passed to the |
The function get_adi()
calls this function by default as its final step,
but some users may want to calculate ADI and ADI-3 values for different
combinations of areas in a given data set. get_adi
(raw_data_only = TRUE)
returns the raw census data used to calculate ADI and ADI-3. Users may
select subsets of such a data set and pipe them into calculate_adi()
.
This function discerns what kind of census data that data
contains (ACS, or
one of the decennial censuses) by checking for the existence of key variables
unique to each kind of data set.
Areas listed as having zero households are excluded from ADI and ADI-3
calculation. Their resulting ADIs and ADI-3s will be NA
.
If calling this function directly (i.e., not via get_adi()
) on a data set
that contains median household income (B19013_001) and does not contain
median family income (B19113_001), median household income will be used in
place of median family income, with a warning()
. See the "Missingness and
imputation" section of get_adi()
.
A tibble
(or sf
) with the same number
of rows as data
. Columns include GEOID
, NAME
, ADI
, Financial Strength
, Economic_Hardship_and_Inequality
, and
Educational_Attainment
. Further columns containing the indicators and raw
values will also be present if keep_indicators = TRUE
.
For more information, see get_adi()
, especially the sections
titled ADI and ADI-3 factor loadings and Missingness and
imputation.
## Not run:
# Wrapped in \dontrun{} because these examples require a Census API key.
raw_census <- get_adi("state", year = 2017, raw_data_only = TRUE)
calculate_adi(raw_census)
calculate_adi(raw_census, keep_indicators = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.