Skip to content

Instantly share code, notes, and snippets.

@walkerke
Created July 27, 2023 17:18
Show Gist options
  • Save walkerke/774ea3cbef9a9b0e7d75037fa332f772 to your computer and use it in GitHub Desktop.
Save walkerke/774ea3cbef9a9b0e7d75037fa332f772 to your computer and use it in GitHub Desktop.
library(tidycensus)
library(tigris)
library(tidyverse)
library(sf)
library(srvyr)
options(tigris_use_cache = TRUE)
sf_area <- metro_divisions() %>%
filter(GEOID %in% c("4186042034", "4186041884"))
sf <- pumas(year = 2019, cb = TRUE, state = "CA") %>%
st_point_on_surface() %>%
st_filter(sf_area) %>%
pull(PUMACE10)
sf_wage_occ <- get_pums(
variables = c("WAGP", "OCCP", "ESR"),
state = "CA",
puma = sf,
survey = "acs1",
year = 2021,
recode = TRUE,
variables_filter = list(
COW = 1:8
),
rep_weights = "person"
) %>%
to_survey()
sf_compare <- sf_wage_occ %>%
mutate(comparison = case_when(
OCCP == "6230" ~ "Carpenters",
OCCP == "1021" ~ "Software developers",
TRUE ~ "Other"
))%>%
filter(comparison != "Other")
sf_compare %>%
group_by(comparison, ESR_label) %>%
summarize(average = survey_mean(WAGP, na.rm = TRUE))
@cgthigpen
Copy link

This was great - I just modified this for a research project. For others looking for occupation codes, you can find them here: https://www.eeoc.gov/federal-sector/management-directive/eeoc-federal-sector-occupation-cross-classification-table

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment