This file contains 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
### Figure 1 #### | |
gg <- gss %>% | |
filter(year <= 2018) %>% | |
gss_reltrad6(reltrad) %>% | |
mutate(abany = case_when(abany == 1 ~ 1, abany == 2 ~ 0)) %>% | |
group_by(year, reltrad) %>% | |
mean_ci(abany, wt = wtssall, ci = .84) %>% | |
na.omit() | |
gg1 <- gss %>% | |
filter(year == 2021) %>% | |
gss_reltrad6(reltrad) %>% | |
mutate(abany = case_when(abany == 1 ~ 1, abany == 2 ~ 0)) %>% | |
group_by(year, reltrad) %>% | |
mean_ci(abany, wt =wtssnrps, ci = .84) %>% | |
na.omit() | |
gg2 <- gss %>% | |
filter(year <= 2018) %>% | |
mutate(abany = case_when(abany == 1 ~ 1, abany == 2 ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(abany, wt = wtssall, ci = .84) %>% | |
na.omit() %>% | |
mutate(reltrad = "Entire Sample") | |
gg3 <- gss %>% | |
filter(year == 2021) %>% | |
gss_reltrad6(reltrad) %>% | |
mutate(abany = case_when(abany == 1 ~ 1, abany == 2 ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(abany, wt =wtssnrps, ci = .84) %>% | |
na.omit() %>% | |
mutate(reltrad = "Entire Sample") | |
graph <- bind_rows(gg, gg1, gg2, gg3) | |
graph %>% | |
filter(reltrad == "Catholic" | reltrad == "Entire Sample") %>% | |
ggplot(., aes(x = year, y = mean, color = reltrad, group = reltrad)) + | |
geom_point(stroke = 1, shape = 21, alpha = .25) + | |
theme_rb() + | |
scale_y_continuous(labels = percent, limits = c(0, .60)) + | |
scale_color_manual(values = c("#412f88", "#fe5308")) + | |
geom_labelsmooth(aes(label = reltrad, linetype = reltrad), method = "loess", formula = y ~ x, family = "font", linewidth = 1, text_smoothing = 30, size = 4, linewidth = 1, boxlinewidth = 0.3) + | |
labs(x = "Year", y = "Share in Favor", title = "In Favor of A Legal Abortion if a Woman Wants One for Any Reason", caption = "@ryanburge\nData: GSS 1972-2021") + | |
save("reltrad_ab_gss.png") | |
### Figure 2 #### | |
gg <- gss %>% | |
filter(reltrad == 4) %>% | |
mutate(pid7 = partyid + 1) %>% | |
cces_pid3(pid7) %>% | |
filter(year <= 2018) %>% | |
mutate(abany = case_when(abany == 1 ~ 1, abany == 2 ~ 0)) %>% | |
group_by(year, pid3) %>% | |
mean_ci(abany, wt = wtssall, ci = .84) %>% | |
na.omit() %>% | |
mutate(type = "Catholics") | |
gg1 <- gss %>% | |
filter(reltrad == 4) %>% | |
mutate(pid7 = partyid + 1) %>% | |
cces_pid3(pid7) %>% | |
filter(year == 2021) %>% | |
gss_reltrad6(reltrad) %>% | |
mutate(abany = case_when(abany == 1 ~ 1, abany == 2 ~ 0)) %>% | |
group_by(year, pid3) %>% | |
mean_ci(abany, wt =wtssnrps, ci = .84) %>% | |
na.omit() %>% | |
mutate(type = "Catholics") | |
gg2 <- gss %>% | |
filter(year <= 2018) %>% | |
mutate(pid7 = partyid + 1) %>% | |
cces_pid3(pid7) %>% | |
mutate(abany = case_when(abany == 1 ~ 1, abany == 2 ~ 0)) %>% | |
group_by(year, pid3) %>% | |
mean_ci(abany, wt = wtssall, ci = .84) %>% | |
na.omit() %>% | |
mutate(type = "Entire Sample") | |
gg3 <- gss %>% | |
filter(year == 2021) %>% | |
mutate(pid7 = partyid + 1) %>% | |
cces_pid3(pid7) %>% | |
mutate(abany = case_when(abany == 1 ~ 1, abany == 2 ~ 0)) %>% | |
group_by(year, pid3) %>% | |
mean_ci(abany, wt =wtssnrps, ci = .84) %>% | |
na.omit() %>% | |
mutate(type = "Entire Sample") | |
graph <- bind_rows(gg, gg1, gg2, gg3) | |
graph %>% | |
ggplot(., aes(x = year, y = mean, color = type, group = type, linetype = type)) + | |
geom_point(stroke = 1, shape = 21, alpha = .25) + | |
theme_rb(legend = TRUE) + | |
facet_wrap(~ pid3) + | |
scale_y_continuous(labels = percent) + | |
scale_color_manual(values = c("#412f88", "#fe5308")) + | |
geom_smooth(se = FALSE) + | |
labs(x = "Year", y = "Share in Favor", title = "In Favor of A Legal Abortion if a Woman Wants One for Any Reason", caption = "@ryanburge\nData: GSS 1972-2021") + | |
save("pid3_ab_gss.png") | |
## Figure 3 #### | |
gg <- cces %>% | |
filter(trad2 == "White Catholic" | trad2 == "Non-White Catholic") %>% | |
cces_attend(pew_churatd) %>% | |
cces_pid3(pid7) %>% | |
mutate(ab = case_when(ab_choice == 1 ~ 1, ab_choice == 2 ~ 0)) %>% | |
group_by(att, year, pid3) %>% | |
mean_ci(ab, wt = weight, ci = .84) | |
gg1 <- cces21 %>% | |
filter(religpew == 2) %>% | |
cces_pid3(pid7) %>% | |
cces_attend(pew_churatd) %>% | |
mutate(ab = case_when(CC21_323a == 1 ~ 1, CC21_323a == 2 ~ 0)) %>% | |
group_by(att, pid3) %>% | |
mean_ci(ab, wt = commonweight, ci = .84) %>% | |
mutate(year = 2021) | |
graph <- bind_rows(gg, gg1) %>% filter(pid3 != "NA") | |
graph %>% | |
filter(att != "NA") %>% | |
ggplot(., aes(x = year, y = mean, color = pid3, group = pid3)) + | |
# error_bar() + | |
geom_point(stroke = 1, shape = 21, fill = "white", alpha = .5) + | |
geom_smooth(se = FALSE, method = lm) + | |
facet_wrap(~ att) + | |
scale_y_continuous(labels = percent, limits = c(0, .85)) + | |
theme_rb(legend = TRUE) + | |
pid3_color()+ | |
labs(x = "Year", y = "Share in Favor", title = "In Favor of A Legal Abortion if a Woman Wants One for Any Reason", subtitle = "Among Catholics - By Mass Attendance", caption = "@ryanburge\nData: CES 2014-2021") + | |
save("cath_att_abort.png") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment