-
-
Save ryanburge/1e0e85906eae6d2c81f04bd956c17c12 to your computer and use it in GitHub Desktop.
MAGA vs GOP
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
gg <- cces19 %>% | |
filter(pid7 == 5 | pid7 == 6 | pid7 == 7) %>% | |
cces_trad(religpew) %>% | |
mutate(app = frcode(CC19_308a == 1 ~ "MAGA", | |
CC19_308a == 2 | CC19_308a == 3 | CC19_308a == 4 ~ "GOP")) %>% | |
group_by(trad2) %>% | |
ct(app, wt = commonweight, show_na = FALSE) | |
gg %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(app))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ trad2, ncol =1, strip.position = "left") + | |
scale_fill_manual(values = c("firebrick3", "#ED820E")) + | |
theme_rb() + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y.left = element_text(angle=0)) + | |
guides(fill = guide_legend(reverse=T, nrow = 1)) + | |
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()) + | |
geom_text(aes(label = ifelse(pct >.05, paste0(pct*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "black") + | |
labs(x = "", y = "", title = "How Republicans Would Fracture By Religious Group", subtitle = "", caption = "@ryanburge\nData: CCES 2019") + | |
ggsave("E://maga_v_gop.png", width = 9, height = 6) | |
gg <- cces19 %>% | |
filter(race == 1) %>% | |
filter(religpew == 1 | religpew == 2) %>% | |
filter(pid7 == 5 | pid7 == 6 | pid7 == 7) %>% | |
cces_attend(pew_churatd) %>% | |
mutate(app = frcode(CC19_308a == 1 ~ "MAGA", | |
CC19_308a == 2 | CC19_308a == 3 | CC19_308a == 4 ~ "GOP")) %>% | |
group_by(att) %>% | |
ct(app, wt = commonweight, show_na = FALSE) %>% | |
na.omit() | |
gg %>% | |
ggplot(., aes(x = att, y = pct, fill = app)) + | |
geom_col(color = "black") + | |
scale_fill_manual(values = c("#ED820E", "firebrick3")) + | |
theme_rb(legend = TRUE) + | |
y_pct() + | |
geom_text(aes(label = paste0(pct*100, '%')), position = position_stack(vjust = 0.5), size = 5, family = "font") + | |
theme(plot.title = element_text(size = 14)) + | |
labs(x = "", y = "", title = "How Republicans Would Fracture By Church Attendance", subtitle = "Among White Christians", caption = "@ryanburge\nData: CCES 2019") + | |
ggsave("E://att_maga_gop.png", type = 'cairo-png', width = 5) | |
fun <- function(df, var, name){ | |
df %>% | |
filter(pid7 == 5 | pid7 == 6 | pid7 == 7) %>% | |
mutate(app = frcode(CC19_308a == 1 ~ "MAGA", | |
CC19_308a == 2 | CC19_308a == 3 | CC19_308a == 4 ~ "GOP")) %>% | |
mutate(vv = case_when({{var}} == 1 ~ 1, | |
{{var}} == 2 ~ 0)) %>% | |
group_by(app) %>% | |
mean_ci(vv, wt = commonweight, ci = .84) %>% | |
mutate(type = name) %>% | |
na.omit() | |
} | |
ttt1 <- cces19 %>% fun(CC19_321a, "Allow as a\nMatter of Choice") | |
ttt2 <- cces19 %>% fun(CC19_321b, "Only Rape,Incest,\nLife of Mother") | |
ttt3 <- cces19 %>% fun(CC19_321c, "Ban After 20 Weeks") | |
ttt4 <- cces19 %>% fun(CC19_321d, "Prohibit Federal Funds\nFor Abortion Services") | |
ttt5 <- cces19 %>% fun(CC19_321e, "Make Completely Illegal") | |
graph <- bind_df("ttt") | |
graph %>% | |
ggplot(., aes(x = type, y = mean, fill = app)) + | |
geom_col(color = "black", position = "dodge") + | |
theme_rb(legend = TRUE) + | |
y_pct() + | |
error_bar() + | |
lab_bar(top = FALSE, type = mean, sz = 5, pos = .045) + | |
scale_fill_manual(values = c("#ED820E", "firebrick3")) + | |
labs(x = "", y = "Share in Favor", title = "Abortion Politics for the MAGA and GOP Parties", caption = '@ryanburge\nData: CCES 2019') + | |
ggsave("E://ab_policy_maga_gop.png", type = "cairo-png") | |
ttt1 <- cces19 %>% fun(CC19_322a, "Don't Use Defense\nFunds for Border Wall") | |
ttt2 <- cces19 %>% fun(CC19_322b, "Withhold Funds\nfrom Sancuary Cities") | |
ttt3 <- cces19 %>% fun(CC19_322c, "Reduce Legal\nImmigration by 50%") | |
ttt4 <- cces19 %>% fun(CC19_322d, "Pathway to Citizenship") | |
ttt5 <- cces19 %>% fun(CC19_322e, "Increase Border\nPatrol Funding") | |
graph <- bind_df("ttt") | |
graph %>% | |
ggplot(., aes(x = type, y = mean, fill = app)) + | |
geom_col(color = "black", position = "dodge") + | |
theme_rb(legend = TRUE) + | |
y_pct() + | |
error_bar() + | |
lab_bar(top = FALSE, type = mean, sz = 5, pos = .045) + | |
scale_fill_manual(values = c("#ED820E", "firebrick3")) + | |
labs(x = "", y = "Share in Favor", title = "Immigration Politics for the MAGA and GOP Parties", caption = '@ryanburge\nData: CCES 2019') + | |
ggsave("E://imm_policy_maga_gop.png", type = "cairo-png") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment