knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message=FALSE, warning=FALSE, echo=FALSE )
library(tidyverse) library(formattable) library(melig)
bind_rows( melig::parents |> mutate(year = lubridate::ym(paste0(year, month))) |> filter(state == "United States") |> mutate(elig_grp = "Parents"), melig::pregnant_women |> mutate(year = lubridate::ym(paste0(year, month))) |> filter(state == "United States") |> mutate(elig_grp = "Pregnant Beneficiaries") ) |> mutate(cutoff = cutoff / 100) |> ggplot(aes(x = year, y = cutoff, colour = elig_grp, fill = elig_grp)) + geom_point() + geom_path() + hrbrthemes::theme_ipsum(grid = "XY", plot_title_size = 12) + hrbrthemes::scale_y_percent(limits = c(0, 2.5)) + theme(legend.position = "top", legend.title = element_blank(), aspect.ratio = 0.618) + labs(x = NULL, y = "Federal Poverl Level", title = "Median State-Level Medicaid Income Eligibility Cutoffs, 2002–2023")
# For parents melig::parents %>% filter(year == 2014) %>% filter(cutoff >= 100) %>% select(state, fips, usps, pa_cutoff = cutoff) %>% formattable(list(pa_cutoff = normalize_bar("lightgreen", 0.2))) # For childless adults melig::childless_adults %>% filter(year == 2014) %>% filter(cutoff >= 100) %>% select(state, fips, usps, ca_cutoff = cutoff) %>% formattable(list(ca_cutoff = normalize_bar("lightgreen", 0.2)))
melig::parents %>% mutate( year = if_else(year == 2009L & month == "December", 2010L, year), year = year %>% as.integer() ) %>% filter(year %in% 2010:2018) %>% select(-month, -state, -fips) %>% tidyr::spread(year, cutoff) %>% rename( pa_2010 = `2010`, pa_2011 = `2011`, pa_2012 = `2012`, pa_2013 = `2013`, pa_2014 = `2014`, pa_2015 = `2015`, pa_2016 = `2016`, pa_2017 = `2017`, pa_2018 = `2018` ) %>% formattable( list( pa_2010 = color_tile("white", "orange"), pa_2011 = color_tile("white", "orange"), pa_2012 = color_tile("white", "orange"), pa_2013 = color_tile("white", "orange"), pa_2014 = color_tile("white", "orange"), pa_2015 = color_tile("white", "orange"), pa_2016 = color_tile("white", "orange"), pa_2017 = color_tile("white", "orange"), pa_2018 = color_tile("white", "orange") ) )
melig::childless_adults %>% mutate(year = as.integer(year)) %>% filter(year %in% 2011:2018) %>% select(-month, -state, -fips) %>% tidyr::spread(year, cutoff) %>% rename( ca_2011 = `2011`, ca_2012 = `2012`, ca_2013 = `2013`, ca_2014 = `2014`, ca_2015 = `2015`, ca_2016 = `2016`, ca_2017 = `2017`, ca_2018 = `2018` ) %>% formattable( list( ca_2011 = color_tile("white", "orange"), ca_2012 = color_tile("white", "orange"), ca_2013 = color_tile("white", "orange"), ca_2014 = color_tile("white", "orange"), ca_2015 = color_tile("white", "orange"), ca_2016 = color_tile("white", "orange"), ca_2017 = color_tile("white", "orange"), ca_2018 = color_tile("white", "orange") ) )
Note: The melig::children
dataset includes two key variables:
type
: Distinguishes between Medicaid and CHIP (Children's Health Insurance Program) programs.agegrp
: Indicates specific age groups within these programs.The age data for CHIP programs (type
== CHIP) is not explicitly provided in the source data. Therefore, in this dataset, a general age range of "0-18" is assigned to the age variable for CHIP. However, certain states' CHIP programs may not cover all children under age 19 in some years.
melig::children # IL melig::children %>% filter(usps == "IL")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.