View source: R/get_acs-poststrat.R
get_acs_cces | R Documentation |
This loads ACS counts via tidycensus and gives them additional labels and renames some variables to later merge with CCES-based regression models.
get_acs_cces(
varlist,
varlab_df = ccesMRPprep::acscodes_df,
year = 2018,
states = NULL,
dataset = "acs1",
geography = "congressional district"
)
varlist |
a vector of variable codes to pull |
varlab_df |
a dataframe that appends the categories based on the varcode |
year |
The year of the ACS to get. Because of data availability limitations, this is capped to 2010-2018. |
states |
A vector of states to subset to. Gets passed onto the new |
dataset |
Which type of ACS to get. Defaults to |
geography |
the type of geography to pull. Currently only supports
|
To run this, you need to have a API token to run get_acs. See census_api_key for details.
get_acs_cces
## Not run:
fm_brm <- yes | responses(n_cell) ~ age + gender + educ + pct_trump + (1|cd)
acs_tab <- get_acs_cces(
varlist = acscodes_age_sex_educ,
varlab_df = acscodes_df,
year = 2018)
# year cd gender age educ race count count_moe
# <dbl> <chr> <fct> <fct> <fct> <fct> <dbl> <dbl>
# 1 2018 AL-01 Male 18 to 24 years HS or Less NA 703 240
# 2 2018 AL-01 Male 18 to 24 years HS or Less NA 5665 581
# 3 2018 AL-01 Male 18 to 24 years HS or Less NA 11764 747
# 4 2018 AL-01 Male 18 to 24 years Some College NA 9528 750
# 5 2018 AL-01 Male 18 to 24 years Some College NA 1389 355
# 6 2018 AL-01 Male 18 to 24 years 4-Year NA 1519 276
poststrat <- get_poststrat(acs_tab, cd_info_2018, fm_brm)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.