Last active
August 7, 2020 20:01
-
-
Save mfherman/d16df6748700ba47ba2298a0f39fb7e3 to your computer and use it in GitHub Desktop.
Estimate race and ethnicity of health care workers by PUMA using PUMS data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Estimate race and ethnicity of health care workers by PUMA | |
# NOTE: this requires the github version of tidycensus | |
# remotes::install_github("walkerke/tidycensus") | |
library(tidycensus) | |
library(tidyverse) | |
# get industry and race vars from census api | |
ind_pums <- get_pums( | |
variables = c("PUMA", "INDP", "RAC1P", "HISP"), | |
state = c("ME", "NH", "VT"), | |
recode = TRUE | |
) | |
# only keep those working in medical industry | |
# create new race/ethnicity recoded variable | |
# and get estimate by state and PUMA | |
ind_pums %>% | |
filter(str_starts(INDP_label, "MED")) %>% | |
mutate( | |
race_eth = case_when( | |
HISP != "01" ~ "Latino", | |
RAC1P == 1 ~ "White", | |
RAC1P == 2 ~ "Black", | |
RAC1P %in% c(3, 4, 5, 7) ~ "Native American", | |
RAC1P == 6 ~ "Asian", | |
TRUE ~ "Other" | |
) | |
) %>% | |
count(ST_label, PUMA, race_eth, wt = PWGTP) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment