-
-
Save ryanburge/8da8325c00e1674a6f1e02cfcbb265f0 to your computer and use it in GitHub Desktop.
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
aaa1 <- cces23 %>% | |
mutate(vv = CC23_343a) %>% | |
mutate(vv = case_when(vv == 1 ~ 1, | |
vv == 2 ~ 0)) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) %>% | |
mutate(type = "Make it illegal for health care professionals to provide someone younger\nthan 18 with medical care for a gender transition") | |
aaa2 <- cces23 %>% | |
mutate(vv = CC23_343b) %>% | |
mutate(vv = case_when(vv == 1 ~ 1, | |
vv == 2 ~ 0)) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) %>% | |
mutate(type = "Prohibit classroom discussion or instruction on sexual orientation and identity in kindergarten to third grade\nor in older grades in 'a manner that is not age-appropriate or developmentally appropriate'") | |
aaa3 <- cces23 %>% | |
mutate(vv = CC23_343c) %>% | |
mutate(vv = case_when(vv == 1 ~ 1, | |
vv == 2 ~ 0)) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) %>% | |
mutate(type = "Prohibit local municipalities and other public bodies from interfering\nwith a person's ability to obtain a gender transition operation") | |
all <- bind_rows(aaa1, aaa2, aaa3) | |
all %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = 1, y = mean, fill = type)) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ type, ncol =1, strip.position = "top") + | |
theme_rb() + | |
y_pct() + | |
scale_fill_manual(values = c("#ff5964", "#00b259", "#35a7ff", "#ffcc00")) + | |
geom_text(aes(y = mean + .035, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 10, family = "font") + | |
theme(strip.text = element_text(size = 14)) + | |
theme(axis.title.y=element_blank(), axis.text.y=element_blank(), axis.ticks.y=element_blank()) + | |
theme(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
theme(plot.title = element_text(size = 22)) + | |
labs(x = "", y = "Share Agreeing", title = "Views of Issues Related to Gender/Sexuality", caption = "@ryanburge\nData: Cooperative Election Study, 2023") | |
save("trans_ces23.png", ht = 5) | |
gg <- cces23 %>% | |
cces_trad(religpew) %>% | |
mutate(vv = CC23_343a) %>% | |
mutate(vv = case_when(vv == 1 ~ 1, | |
vv == 2 ~ 0)) %>% | |
group_by(trad2) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) | |
gg %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = reorder(trad2, mean), y = mean, fill = trad2)) + | |
geom_col(color = "black") + | |
coord_flip() + | |
theme_rb() + | |
error_bar() + | |
scale_fill_manual(values = c(moma.colors("Warhol", 16))) + | |
scale_y_continuous(labels = percent) + | |
geom_text(aes(y = .05, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 10, family = "font") + | |
geom_text(aes(y = .05, label = ifelse(trad2 == "White Evangelical" | trad2 == "Hindu" | trad2 == "Non-White Evangelical" | trad2 == "Agnostic" | trad2 == "Black Protestant" | trad2 == "Atheist", paste0(lab*100, '%'), "")), position = position_dodge(width = .9), size = 10, family = "font", color = "white") + | |
labs(x = "", y = "Share Agreeing", title = "Make it illegal for health care professionals to provide someone younger\nthan 18 with medical care for a gender transition", caption = "@ryanburge\nData: Cooperative Election Study, 2023") | |
save("trans_kids_ces23.png", ht = 9) | |
cces_pid3 <- function(df, var){ | |
df %>% | |
mutate(pid3 = frcode({{var}} == 1 | {{var}} == 2 | {{var}} == 3 ~ "Dem", | |
{{var}} == 4 ~ "Ind", | |
{{var}} == 5 | {{var}} == 6 | {{var}} == 7 ~ "Rep")) | |
} | |
gg <- cces23 %>% | |
cces_trad(religpew) %>% | |
mutate(vv = CC23_343a) %>% | |
mutate(vv = case_when(vv == 1 ~ 1, | |
vv == 2 ~ 0)) %>% | |
cces_pid3(pid7) %>% | |
group_by(trad2, pid3) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) %>% filter(pid3 != "NA") | |
gg %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = pid3, y = mean, fill = pid3)) + | |
geom_col(color = "black") + | |
facet_wrap(~ trad2) + | |
pid3_fill() + | |
theme_rb() + | |
y_pct() + | |
error_bar() + | |
lab_bar(top = FALSE, type = lab, pos = .08, sz = 7) + | |
labs(x = "", y = "Share Agreeing", title = "Make it illegal for health care professionals to provide someone younger\nthan 18 with medical care for a gender transition", caption = "@ryanburge\nData: Cooperative Election Study, 2023") | |
save("pid3_trans_minor_trad2.png", ht = 10) | |
gg %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = reorder(trad2, mean), y = mean, fill = trad2)) + | |
geom_col(color = "black") + | |
coord_flip() + | |
theme_rb() + | |
error_bar() + | |
scale_fill_manual(values = c(moma.colors("Warhol", 16))) + | |
scale_y_continuous(labels = percent) + | |
geom_text(aes(y = .05, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 10, family = "font") + | |
geom_text(aes(y = .05, label = ifelse(trad2 == "White Evangelical" | trad2 == "Hindu" | trad2 == "Non-White Evangelical" | trad2 == "Agnostic" | trad2 == "Black Protestant" | trad2 == "Atheist", paste0(lab*100, '%'), "")), position = position_dodge(width = .9), size = 10, family = "font", color = "white") + | |
labs(x = "", y = "Share Agreeing", title = "Make it illegal for health care professionals to provide someone younger\nthan 18 with medical care for a gender transition", caption = "@ryanburge\nData: Cooperative Election Study, 2023") | |
save("trans_kids_ces23.png", ht = 9) | |
gg1 <- cces23 %>% | |
cces_trad(religpew) %>% | |
mutate(vv = CC23_343a) %>% | |
mutate(vv = case_when(vv == 1 ~ 1, | |
vv == 2 ~ 0)) %>% | |
group_by(trad2) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) %>% | |
select(trad2, trans = mean, n) | |
gg2 <- cces23 %>% | |
cces_trad(religpew) %>% | |
mutate(dem = case_when(pid7 == 1 | pid7 == 2 | pid7 == 3 ~ 1, | |
pid7 <= 7 ~ 0)) %>% | |
group_by(trad2) %>% | |
mean_ci(dem, wt = commonweight, ci = .84) %>% | |
select(trad2, dem = mean) | |
both <- left_join(gg1, gg2) | |
both$type <- c("a", "a", "a", "a", "a", "a", "b", "a", "b", "b", "b", "b", "c", "c", "c", "d") | |
library(ggrepel) | |
both %>% | |
ggplot(., aes(x = dem, y = trans)) + | |
geom_point(aes(size = n, color = type), show.legend = FALSE, stroke = 1, shape = 21) + | |
geom_smooth(se = FALSE, method = lm, color = "dodgerblue4", linetype = "twodash") + | |
geom_text_repel(data = both, aes(x = dem, y = trans, label = trad2), family = "font", size = 4) + | |
theme_rb() + | |
y_pct() + | |
x_pct() + | |
scale_color_manual(values = c("#ff5964", "#00b259", "#35a7ff", "#ffcc00")) + | |
labs(x = "Share Who Identify as Democrats", y = "Share Favoring a Ban on Transition Surgery for Minors", title = "Relationship Between Partisanship and Views of Transgender Issues", caption = "@ryanburge\nData: Cooperative Election Study, 2023") | |
save("trans_dem_scatter.png") | |
gg1 <- cces23 %>% | |
filter(religpew == 2) %>% | |
cces_race(race) %>% | |
filter(pid7 == 1 | pid7 == 2 | pid7 == 3) %>% | |
mutate(vv = CC23_343a) %>% | |
mutate(vv = case_when(vv == 1 ~ 1, | |
vv == 2 ~ 0)) %>% | |
group_by(race) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) %>% | |
mutate(type = "Catholics") | |
gg2 <- cces23 %>% | |
filter(religpew == 1) %>% | |
filter(pew_bornagain == 1) %>% | |
cces_race(race) %>% | |
filter(pid7 == 1 | pid7 == 2 | pid7 == 3) %>% | |
mutate(vv = CC23_343a) %>% | |
mutate(vv = case_when(vv == 1 ~ 1, | |
vv == 2 ~ 0)) %>% | |
group_by(race) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) %>% | |
mutate(type = "Evangelicals") | |
gg3 <- cces23 %>% | |
filter(religpew == 1) %>% | |
filter(pew_bornagain == 2) %>% | |
cces_race(race) %>% | |
filter(pid7 == 1 | pid7 == 2 | pid7 == 3) %>% | |
mutate(vv = CC23_343a) %>% | |
mutate(vv = case_when(vv == 1 ~ 1, | |
vv == 2 ~ 0)) %>% | |
group_by(race) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) %>% | |
mutate(type = "Non-Evangelicals") | |
graph <- bind_rows(gg1, gg2, gg3) %>% filter(race == "White" | race == "Black" | race == "Hispanic") | |
graph %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = race, y = mean, fill = race)) + | |
geom_col(color = "black") + | |
facet_wrap(~ type) + | |
theme_rb() + | |
y_pct() + | |
error_bar() + | |
lab_bar(top = FALSE, type = lab, pos = .04, sz = 10) + | |
theme(strip.text = element_text(size = 20)) + | |
scale_fill_manual(values = c("#F06A63", "#FFCC3D", '#96CBA6')) + | |
labs(x = "", y = "", title = "Support for a Ban on Minors Having Gender Transition Surgery Among Christian Democrats", caption = "@ryanburge\nData: Cooperative Election Study, 2023") | |
save("trans_xtn_dems.png") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment