I have this table that I made by joining two other tables created with CPS data. I joined the two by age
and sex
and then I calculated the labor force participation rate for each age and sex in this hypothetical economy. Now I need to collapse the table by age
and sex
so that I can get the total population labor force participation rate, but for some reason the ungroup()
command just isn't working. I've included an excerpt of the data in the attached image link and the code I have so far.
cps_summary2 <- left_join(cps_summary2015, cps_summary1995,
by = c("age", "sex"))
cps_summary2 <- cps_summary2 %>% mutate(estWorkingAgePop = cps_summary2$total_pop.x * cps_summary2$lfpr.y)
cps_summary2 <- cps_summary2 %>% mutate(laborforcerate = estWorkingAgePop/total_pop.y) %>%
ungroup(cps_summary2, by = c("age", "sex"))