View source: R/get_acs-poststrat.R
get_poststrat | R Documentation |
Formats a post-strat table from ACS and district-level data
get_poststrat(cleaned_acs, dist_data = NULL, formula)
cleaned_acs |
An output of get_acs_cces. The count of people in
each cell must be under the variable |
dist_data |
District-level (in this case congressional district-level) information to merge in |
formula |
the model formula used to fit the multilevel regression model, with one
term on the LHS: e.g. |
get_acs_cces
## Not run:
fm_brm <- response ~ age + gender + educ + pct_trump + (1|cd)
acs_tab <- get_acs_cces(
varlist = acscodes_age_sex_educ,
varlab_df = acscodes_df,
year = 2018)
poststrat <- get_poststrat(acs_tab, cd_info_2018, fm_brm)
head(poststrat)
# age gender educ pct_trump cd count
# <fct> <fct> <fct> <dbl> <chr> <dbl>
# 1 18 to 24 years Male HS or Less 0.049 NY-15 24216
# 2 18 to 24 years Male HS or Less 0.054 NY-13 18014
# 3 18 to 24 years Male HS or Less 0.068 CA-13 14153
# 4 18 to 24 years Male HS or Less 0.07 PA-03 15750
# 5 18 to 24 years Male HS or Less 0.087 CA-12 6270
# 6 18 to 24 years Male HS or Less 0.092 IL-07 18734
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.