inst/shiny-examples/LagSelectionBias/plotEducation.R

plotEducation <- function(education_age, education_race, education_sex) {
    load("education_data.rda")

    graph_data <-
        education_data %>%
        filter(Age_Group == education_age) %>%
        filter(Race %in% education_race) %>%
        filter(Sex %in% education_sex) %>%
        filter(Education != "Missing/Unknown") %>%
        mutate(Birth_Year = Year - 30) %>%
        mutate(Population = ifelse(!is.na(CPS_Population), CPS_Population,
                                   Census_Population)) %>%
        group_by(Birth_Year, Education) %>%
        summarise(Population = sum(Population))

    graph_data %>%
        ggplot(aes(Birth_Year, Population)) +
        geom_area(aes(fill = Education), position = "fill") +
        theme_minimal() +
        xlab("Birth Year") +
        ylab("Proportion") +
        theme(legend.position = "none", legend.title = element_blank())
}
schifferl/LagSelectionBias documentation built on May 29, 2019, 3:38 p.m.