-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
78 lines (62 loc) · 2.34 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
output: github_document
editor_options:
chunk_output_type: console
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# About `{aca.medicaid.expansion}`
The package `{aca.medicaid.expansion}` contains a dataset `status`, which
includes the status of state action on the ACA Medicaid expansion decision.
The first version of the data is from [the Kaiser Family Foundation](https://www.kff.org/medicaid/issue-brief/status-of-state-medicaid-expansion-decisions-interactive-map/).
# Installation
You can install the current version of `{aca.medicaid.expansion}` from Github
with:
``` r
# install.packages("remotes")
packageVersion("remotes") # Version 2.2.0 required
remotes::install_github("jjchern/aca.medicaid.expansion")
```
# Examples
```{r examples, fig.width = 6, fig.asp = 1.618, out.width = "70%", fig.align = "center"}
library(tidyverse)
library(lubridate)
# Data
aca.medicaid.expansion::status
# Convert the dataset to a state-year panel
add_st_yr_dummy = function(dta, bgn_yr, end_yr) {
dta %>%
mutate(year = list(bgn_yr:end_yr)) %>%
unnest(year) %>%
mutate(round_exp_year = round_date(expansion_date, "year")) %>%
mutate(round_exp_year = year(round_exp_year)) %>%
mutate(expansion = if_else(year < round_exp_year |
is.na(round_exp_year), FALSE, TRUE)) %>%
select(-round_exp_year)
}
aca.medicaid.expansion::status %>%
add_st_yr_dummy(bgn_yr = 2010, end_yr = 2020) %>%
select(usps, year, expansion) %>%
print() -> st_yr_expansion
# Plot the expansion status for each state
st_yr_expansion %>%
mutate(usps = forcats::fct_rev(usps)) %>%
mutate(year = as.character(year)) %>%
mutate(expansion = if_else(expansion, "Yes", "No")) %>%
ggplot(aes(x = year, y = usps, fill = expansion)) +
geom_tile(colour = "white") +
labs(x = NULL, y = NULL, fill = "Expanded?",
title = "Status of State Action on the Medicaid Expansion Decision",
subtitle = "States' decisions as of October 16, 2020",
caption = "Source: the Kaiser Family Foundatio") +
hrbrthemes::theme_ipsum_rc(plot_title_size = 15) +
theme(legend.position = "top") +
scale_fill_brewer()
```