Uncategorized code snippets

Author

EPI data team

Uncategorized code snippets

Union density vs union coverage

Universe definitions for union density and union coverage include paid employed workers 16 and older, not self-employed or self-incorporated. 

This code will allow the user to reproduce the year-over-year share represented by a union

library(tidyverse)
library(epiextractr)

load_org(2020:2024, year, age, cow1, emp, union, orgwgt) |> 
  filter(age >= 16, cow1 < 6, emp == 1) |> 
  summarize(union_coverage = weighted.mean(union, w = orgwgt/12), .by = year) 

This code will allow the user to reproduce the year-over-year share in a union

load_org(2020:2024, year, age, cow1, emp, unmem, orgwgt) |> 
  filter(age >= 16, cow1 < 6, emp == 1) |> 
  summarize(union_coverage = weighted.mean(unmem, w = orgwgt/12), .by = year) 

Universe definitions for specific policy areas 

Right to work 

Refer to this Github repo for code that assigns RTW status by year by state to CPS microdata, as well as an example snippet on how to use it (see example on EARN Code Library).  

Back to top