Calculate ACS proportions from counts
calculate_acs_proportions.RdConverts ACS count columns to proportions for each geography, normalizing by total population. Use to prepare ACS reference data for ethnicity imputation or other proportional analyses.
Value
data.table. ACS proportions by geography. Columns:
GEOID— geographic identifier f_*— fraction of population for each ethnicity level Rows: one per geography. Keys: ( GEOID).
Details
Identifies count columns prefixed with
n_(excludingn_total).Computes fraction columns (
f_*) as count divided byn_totalfor each row.Fills missing fractions with zero.
Checks that fractions sum to 1 (within tolerance); drops rows failing this check.
Removes count columns, returning only fraction columns and identifiers.
Assumes input is a wide-format ACS data.table with
n_totaland ethnicity counts.
See also
get_acs_ethnicity, impute_ethnicity
Other imputation utilities:
get_acs_ethnicity(),
get_acs_race(),
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()
Examples
## Not run:
acs_wide <- data.table(GEOID = "12345", n_total = 100, n_hispanic = 20, n_not_hispanic = 80)
calculate_acs_proportions(acs_wide)
#> Error in calculate_acs_proportions(acs_wide): could not find function "calculate_acs_proportions"
## End(Not run)