Created
July 31, 2019 16:23
-
-
Save svmiller/9bd78d1b1517762bf8a97ec8ff34efe9 to your computer and use it in GitHub Desktop.
“fReE sTuFf fRoM tHe gOvErnMeNt dOeS nOt pLaY wElL iN tHe mIdWeSt.”
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(stevemisc) | |
GSS <- readRDS("~/Dropbox/data/gss/GSS_spss-2018/gss7218.rds") | |
GSS %>% | |
mutate(regioncondensed = NA, | |
regioncondensed = ifelse(region == 8 | region == 9, "West", regioncondensed), | |
regioncondensed = ifelse(region == 3 | region == 4, "Midwest", regioncondensed), | |
regioncondensed = ifelse(region == 5 | region == 6 | region == 7, "South", regioncondensed), | |
regioncondensed = ifelse(region == 1 | region == 2, "Northeast", regioncondensed)) %>% | |
select(year, regioncondensed, natheal, natsoc) %>% | |
mutate(nathealtm = carr(natheal, "1:2=0; 3=1"), | |
natsoctm = carr(natsoc, "1:2=0; 3=1"), | |
nathealtl = carr(natheal, "2:3=0; 1=1"), | |
natsoctl = carr(natsoc, "2:3=0; 1=1"),) -> McCaskill | |
McCaskill %>% | |
group_by(regioncondensed, year) %>% | |
summarize(perchealtm = mean(nathealtm, na.rm=T), | |
percsoctm = mean(natsoctm, na.rm=T)) %>% | |
group_by(regioncondensed, year) %>% | |
gather(Category, value, 3:4) %>% | |
mutate(Category = ifelse(Category == "perchealtm", | |
"Spending Too Much on Health Care", | |
"Spending Too Much on Social Security")) %>% | |
ggplot(.,aes(year, value, color=Category, linetype=Category)) + | |
theme_steve_web() + | |
geom_line(size=1.1) + facet_wrap(~regioncondensed) + | |
scale_y_continuous(labels=scales::percent) + | |
scale_x_continuous(breaks = seq(1970, 2020, by=4)) + | |
scale_color_brewer(palette="Set1") + | |
labs(x = "Year", | |
y = "Percent of Respondents in a Given Year Who Think the U.S. is Spending Too Much on this Public Good", | |
title = "Only About Five Percent of Americans, by Region, Think the U.S. Spends Too Much on Health Care and Social Security", | |
subtitle = "Unsurprisingly, the spikes on the health care item in 2010 are entirely Obamacare freakouts that propelled the Tea Party to power.", | |
caption = "Data: General Social Survey, 1972-2018") | |
McCaskill %>% | |
group_by(regioncondensed, year) %>% | |
summarize(perchealtl = mean(nathealtl, na.rm=T), | |
percsoctl = mean(natsoctl, na.rm=T)) %>% | |
group_by(regioncondensed, year) %>% | |
gather(Category, value, 3:4) %>% | |
mutate(Category = ifelse(Category == "perchealtl", | |
"Spending Too Little on Health Care", | |
"Spending Too Little on Social Security")) %>% | |
ggplot(.,aes(year, value, color=Category, linetype=Category)) + | |
theme_steve_web() + | |
geom_line(size=1.1) + facet_wrap(~regioncondensed) + | |
scale_y_continuous(labels=scales::percent) + | |
scale_x_continuous(breaks = seq(1970, 2020, by=4)) + | |
scale_color_brewer(palette="Set1") + | |
labs(x = "Year", | |
y = "Percent of Respondents in a Given Year Who Think the U.S. is Spending Too Little on this Public Good", | |
title = "About 60-70% of Americans, by Region, Think the U.S. Spends Too Little on Health Care and Social Security", | |
subtitle = "Unsurprisingly, the dips on the health care item in 2010 are entirely Obamacare freakouts that propelled the Tea Party to power.", | |
caption = "Data: General Social Survey, 1972-2018") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment