Summary: BUNMD Birthplace Coverage.

## Library packages 
library(tidyverse)
library(data.table)
library(censocdev)
library(cowplot)
library(gt)
library(ipumsr)
library(here)
library(janitor)
bunmd <- fread("/censoc/data/censoc_v2/bunmd_v2.csv")
bunmd_tab <- bunmd %>% 
  group_by(byear, sex) %>% 
  summarize(bpl_available = mean(!is.na(bpl)))
bunmd_bpl_plot <- bunmd_tab %>% 
  mutate(sex = case_when(
    sex == 1 ~ "Men",
    sex == 2 ~ "Women"
  )) %>% 
  filter(byear %in% 1900:1940) %>% 
  filter(!is.na(sex)) %>% 
  ggplot(aes(x = byear, y = bpl_available, shape = sex, linetype = sex)) + 
  geom_line() + 
  geom_point() + 
  theme_cowplot() + 
  ylim(0, 1) + 
  labs(x = "Birth Year",
       y = "Proportion Birthplace Available") + 
  theme(legend.position = "bottom", legend.title = element_blank()) 


ggsave(bunmd_bpl_plot, filename = here("vignettes/assess_match_quality/figs/bunmd_bpl_plot.pdf"), height = 5, width = 7)


caseybreen/wcensoc documentation built on Nov. 21, 2024, 5:15 a.m.