Fetch and format ACS race table for imputation
get_acs_race.RdRetrieves and processes ACS race data for survey race imputation, supporting custom and collapsed race categories. Uses explicit regex patterns to match and collapse race categories to target levels. Use for imputing race in survey data using ACS reference.
Value
data.table. Block group GEOID and race fraction columns. Columns:
bg_geoid— block group GEOID f_*— fraction of households in each race bin (e.g., f_white,f_afam) Rows: one per block group. Keys: (bg_geoid).
Details
Fetches ACS table for race using settings and ACS year.
Collapses and recodes race categories to match target levels using regex patterns:
str_detect(label, "white alone")→ "white"str_detect(label, "black or african american alone")→ "afam"str_detect(label, "american indian and alaska native alone")→ "native"str_detect(label, "asian alone")→ "asian"str_detect(label, "native hawaiian and other pacific islander alone")→ "pacific"str_detect(label, "some other race alone|not listed above")→ "other"str_detect(label, "two or more races:$")→ "multiple"str_detect(label, "estimate!!total:$")→ "total"
Collapses unmatched categories into 'other'.
Matches target levels using regex:
str_detect(rl, label2)for each target levelrl.Returns data.table with block group GEOID and race fraction columns (e.g.,
f_white,f_afam).Assumes settings include ACS tables and target levels; errors if required columns are missing.
Settings
acs_year(direct): ACS year for race table. Default from settings.acs_tables[['race']](direct): ACS table name for race. Default from settings.targets[['p_race']]$levels(direct): Target race levels for collapsing categories.
See also
fetch_acs
Other imputation utilities:
calculate_acs_proportions(),
get_acs_ethnicity(),
get_hh_person_sums(),
impute_ethnicity(),
impute_gender(),
impute_income_nonrelatives(),
impute_income_pnta(),
impute_race(),
make_binary(),
prep_hhs_for_income_imputation(),
prepare_acs_income(),
prepare_ethnicity_labels(),
prepare_ethnicity_survey_data(),
prepare_impute_targets(),
prepare_income_fit_dt(),
prepare_persons_dt(),
update_hh_income_imputed()