White Evangelicals Mormons
## PID7 #### | |
gg <- cces18 %>% | |
mutate(grp = frcode(evangelical == 1 & race == 1 ~ "White Evangelicals", | |
religpew == 3 ~ "Mormon")) %>% | |
group_by(grp) %>% | |
mutate(pid = frcode(pid7 == 1 ~ "Str. Dem.", | |
pid7 == 2 ~ "Not Str. Dem.", | |
pid7 == 3 ~ "Lean Dem.", | |
pid7 == 4 ~ "Independent", | |
pid7 == 5 ~ "Lean Rep.", | |
pid7 == 6 ~ "Not Str. Rep.", | |
pid7 == 7 ~ "Str. Rep.")) %>% | |
ct(pid, wt = commonpostweight, show_na = FALSE) | |
gg %>% | |
filter(grp != "NA") %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(pid))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ grp, ncol =1, strip.position = "left") + | |
scale_fill_manual(values = c("#8D021F", "#B2182B","#EF8A62","azure4", "#67A9CF", "#2166AC", "#000080", "darkorchid")) + | |
theme_gg("Abel") + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y = element_text(angle = 180)) + | |
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 = "white") + | |
labs(x = "", y = "", title = "Partisan Distribution", subtitle = "", caption = "@ryanburge\nData: CCES 2018") + | |
ggsave("E://evan_mormon.png", width = 9, height = 3) | |
##IDEO5 #### | |
gg <- cces18 %>% | |
mutate(grp = frcode(evangelical == 1 & race == 1 ~ "White Evangelicals", | |
religpew == 3 ~ "Mormon")) %>% | |
group_by(grp) %>% | |
mutate(ideo = frcode(ideo5 == 1 ~ "Very Liberal", | |
ideo5 == 2 ~ "Liberal", | |
ideo5 == 3 ~ "Moderate", | |
ideo5 == 4 ~ "Conservative", | |
ideo5 == 5 ~ "Very Conservative")) %>% | |
ct(ideo, wt = commonpostweight, show_na = FALSE) %>% | |
na.omit() | |
gg %>% | |
filter(grp != "NA") %>% | |
ggplot(., aes(x = 1, y = pct, fill = fct_rev(ideo))) + | |
geom_col(color = "black") + | |
coord_flip() + | |
facet_wrap(~ grp, ncol =1, strip.position = "left") + | |
scale_fill_manual(values = c("#B2182B","#EF8A62","azure4", "#67A9CF", "#2166AC")) + | |
theme_gg("Abel") + | |
theme(legend.position = "bottom") + | |
scale_y_continuous(labels = percent) + | |
theme(strip.text.y = element_text(angle = 180)) + | |
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 = "white") + | |
labs(x = "", y = "", title = "Ideological Distribution", subtitle = "", caption = "@ryanburge\nData: CCES 2018") + | |
ggsave("E://evan_mormon_ideo.png", width = 9, height = 3) | |
## Votes #### | |
gg08 <- cces08 %>% | |
mutate(grp = frcode(evangelical == 1 & race == 1 ~ "White Evangelicals", | |
religpew == 3 ~ "Mormon")) %>% | |
mutate(vote = frcode(CC410 == 1 ~ "Republican", CC410 == 2 ~ "Democrat", CC410 >= 3 & CC410 <= 7 ~ "All Others")) %>% | |
group_by(grp) %>% | |
ct(vote, wt = V201, show_na = FALSE) %>% | |
na.omit() %>% | |
mutate(year = 2008) | |
gg12 <- cces12 %>% | |
mutate(grp = frcode(evangelical == 1 & race == 1 ~ "White Evangelicals", | |
religpew == 3 ~ "Mormon")) %>% | |
mutate(vote = frcode(CC410a == 2 ~ "Republican", CC410a == 1 ~ "Democrat", CC410a ==4 ~ "All Others")) %>% | |
group_by(grp) %>% | |
ct(vote, wt = weight_vv_post, show_na = FALSE) %>% | |
na.omit() %>% | |
mutate(year = 2012) | |
gg16 <- cces16 %>% | |
mutate(grp = frcode(evangelical == 1 & race == 1 ~ "White Evangelicals", | |
religpew == 3 ~ "Mormon")) %>% | |
mutate(vote = frcode(CC16_410a == 1 ~ "Republican", CC16_410a == 2 ~ "Democrat", | |
CC16_410a == 3 | CC16_410a == 4 | CC16_410a == 5 | CC16_410a == 8 ~ "All Others")) %>% | |
group_by(grp) %>% | |
ct(vote, wt = commonweight_vv_post, show_na = FALSE) %>% | |
na.omit() %>% | |
mutate(year = 2016) | |
graph <- bind_rows(gg08, gg12, gg16) | |
graph %>% | |
ggplot(., aes(x = vote, y = pct, fill = grp)) + | |
geom_col(color = "black", position = "dodge") + | |
facet_wrap(~ year) + | |
y_pct() + | |
scale_fill_manual(values = c("#00539CFF", "#EEA47FFF")) + | |
theme_gg("Abel", legend = TRUE) + | |
lab_bar(top = TRUE, type = pct, sz = 3, pos = .02) + | |
labs(x = "", y = "", title = "Vote Choice in Presidential Elections", caption = "@ryanburge\nData: CCES 2008-2016") + | |
ggsave("E://mormon_evan_vote.png", type = "cairo-png", width = 7) | |
## Issue Areas #### | |
fun <- function(df, var, name){ | |
df %>% | |
mutate(grp = frcode(evangelical == 1 & race == 1 ~ "White Evangelicals", | |
religpew == 3 ~ "Mormon")) %>% | |
mutate(vv = case_when({{var}} == 1 ~ 1, | |
{{var}} == 2 ~ 0)) %>% | |
group_by(grp) %>% | |
mean_ci(vv, ci = .84) %>% | |
na.omit() %>% | |
mutate(type = name) | |
} | |
yyy1 <- cces18 %>% fun(CC18_320a, "Background Checks\non Gun Sales") | |
yyy2 <- cces18 %>% fun(CC18_320c, "Ban Assault\nRifles") | |
yyy3 <- cces18 %>% fun(CC18_320d, "Make it Easier to get\nConceal-Carry Permit") | |
gg <- bind_df("yyy") | |
one <- gg %>% | |
ggplot(., aes(x = type, y = mean, fill = grp)) + | |
geom_col(color = "black", position = "dodge") + | |
y_pct() + | |
scale_fill_manual(values = c("#00539CFF", "#EEA47FFF")) + | |
theme_gg("Abel") + | |
error_bar() + | |
lab_bar(top = FALSE, type = mean, sz = 4, pos = .05) + | |
labs(x = "", y = "Share in Favor", title = "Policy Differences in White Evangelicals and Mormons", caption = "", subtitle = "Gun Control") + | |
ggsave("E://mormon_evan_guns.png", type = "cairo-png", width = 7) | |
ttt1 <- cces18 %>% fun(CC18_321a, "Always Allow\nas a Choice") | |
ttt2 <- cces18 %>% fun(CC18_321b, "Only in\nRape,Incest,\nLife of Mother") | |
ttt3 <- cces18 %>% fun(CC18_321c, "Ban After\n20 Weeks") | |
ttt4 <- cces18 %>% fun(CC18_321d, "Employeers Deny\nAbortion Coverage\nin Insurance") | |
ttt5 <- cces18 %>% fun(CC18_321e, "Prohibit\nFederal Funds") | |
ttt6 <- cces18 %>% fun(CC18_321f, "Make\nCompletely\nIllegal") | |
gg <- bind_df("ttt") | |
two <- gg %>% | |
ggplot(., aes(x = type, y = mean, fill = grp)) + | |
geom_col(color = "black", position = "dodge") + | |
y_pct() + | |
scale_fill_manual(values = c("#00539CFF", "#EEA47FFF")) + | |
theme_gg("Abel") + | |
error_bar() + | |
lab_bar(top = FALSE, type = mean, sz = 4, pos = .05) + | |
labs(x = "", y = "Share in Favor", title = "", caption = "", subtitle = "Abortion") + | |
ggsave("E://mormon_evan_ab.png", type = "cairo-png", width = 7) | |
qqq1 <- cces18 %>% fun(CC18_322a, "Increase Funding\nby $25 billion") | |
qqq2 <- cces18 %>% fun(CC18_322b, "DACA") | |
qqq3 <- cces18 %>% fun(CC18_322c_new, "Eliminate Visa\nLottery and Family\nBased Migration") | |
qqq4 <- cces18 %>% fun(CC18_322c, "Withhold Fed.\nFunds for \nSancturay Cities") | |
qqq5 <- cces18 %>% fun(CC18_322f, "Imprison Repeated\nBorder Crossers") | |
gg <- bind_df("qqq") | |
three <- gg %>% | |
ggplot(., aes(x = type, y = mean, fill = grp)) + | |
geom_col(color = "black", position = "dodge") + | |
y_pct() + | |
scale_fill_manual(values = c("#00539CFF", "#EEA47FFF")) + | |
theme_gg("Abel", legend = TRUE) + | |
error_bar() + | |
lab_bar(top = FALSE, type = mean, sz = 4, pos = .05) + | |
labs(x = "", y = "Share in Favor", title = "", caption = "@ryanburge\nData: CCES 2018", subtitle = "Immigration") + | |
ggsave("E://mormon_evan_imm.png", type = "cairo-png", width = 7) | |
library(patchwork) | |
all <- one / two / three | |
ggsave("E://all_evan_mormon.png", type = "cairo-png", all, height = 10, width = 7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment