-
-
Save ryanburge/238a0695e737412e80ddee5863640ad4 to your computer and use it in GitHub Desktop.
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
| aaa1 <- cces21 %>% | |
| cces_trad(religpew) %>% | |
| mutate(app = CC21_315a) %>% | |
| mutate(app = frcode(app == 4 ~ "Strongly Disapprove", | |
| app == 3 ~ "Somewhat Disapprove", | |
| app == 2 ~ "Somewhat Approve", | |
| app == 1 ~ "Strongly Approve")) %>% | |
| group_by(trad2) %>% | |
| ct(app, wt = commonweight, show_na = FALSE) %>% | |
| mutate(year = "2021") | |
| aaa2 <- cces22 %>% | |
| cces_trad(religpew) %>% | |
| mutate(app = CC22_320a) %>% | |
| mutate(app = frcode(app == 4 ~ "Strongly Disapprove", | |
| app == 3 ~ "Somewhat Disapprove", | |
| app == 2 ~ "Somewhat Approve", | |
| app == 1 ~ "Strongly Approve")) %>% | |
| group_by(trad2) %>% | |
| ct(app, wt = commonweight, show_na = FALSE) %>% | |
| mutate(year = "2022") | |
| aaa3 <- cces23 %>% | |
| cces_trad(religpew) %>% | |
| mutate(app = CC23_312a) %>% | |
| mutate(app = frcode(app == 4 ~ "Strongly Disapprove", | |
| app == 3 ~ "Somewhat Disapprove", | |
| app == 2 ~ "Somewhat Approve", | |
| app == 1 ~ "Strongly Approve")) %>% | |
| group_by(trad2) %>% | |
| ct(app, wt = commonweight, show_na = FALSE) %>% | |
| mutate(year = "2023") | |
| gg <- bind_rows(aaa1, aaa2, aaa3) | |
| gg %>% | |
| filter(trad2 == "White Evangelical" | trad2 == "Non-White Evangelical") %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = fct_rev(year), y = pct, fill = fct_rev(app))) + | |
| geom_col(color = "black") + | |
| coord_flip() + | |
| facet_wrap(~ trad2, ncol =1, strip.position = "top") + | |
| theme_rb() + | |
| scale_fill_manual(values = c("dodgerblue4", "dodgerblue1", "firebrick1", "firebrick4")) + | |
| 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(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
| geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "black") + | |
| geom_text(aes(label = ifelse(app == "Strongly Disapprove", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| geom_text(aes(label = ifelse(app == "Strongly Approve", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| theme(plot.title = element_text(size = 16)) + | |
| theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) + | |
| theme(strip.text.x.top = element_text(size = 22)) + | |
| labs(x = "", y = "", title = "Joe Biden's Approval Rating Among Evangelicals", caption = "@ryanburge\nData: Cooperative Election Study, 2021-2023") | |
| save("biden_app_evangelicals.png", wd = 9, ht = 6) | |
| gg %>% | |
| filter(trad2 == "Mainline" | trad2 == "Black Protestant") %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = fct_rev(year), y = pct, fill = fct_rev(app))) + | |
| geom_col(color = "black") + | |
| coord_flip() + | |
| facet_wrap(~ trad2, ncol =1, strip.position = "top") + | |
| theme_rb() + | |
| scale_fill_manual(values = c("dodgerblue4", "dodgerblue1", "firebrick1", "firebrick4")) + | |
| 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(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
| geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "black") + | |
| geom_text(aes(label = ifelse(app == "Strongly Disapprove", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| geom_text(aes(label = ifelse(app == "Strongly Approve", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| theme(plot.title = element_text(size = 16)) + | |
| theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) + | |
| theme(strip.text.x.top = element_text(size = 22)) + | |
| labs(x = "", y = "", title = "Joe Biden's Approval Rating Among Mainline and Black Protestants", caption = "@ryanburge\nData: Cooperative Election Study, 2021-2023") | |
| save("biden_app_ml_bprot.png", wd = 9, ht = 6) | |
| gg %>% | |
| filter(trad2 == "White Catholic" | trad2 == "Non-White Catholic") %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = fct_rev(year), y = pct, fill = fct_rev(app))) + | |
| geom_col(color = "black") + | |
| coord_flip() + | |
| facet_wrap(~ trad2, ncol =1, strip.position = "top") + | |
| theme_rb() + | |
| scale_fill_manual(values = c("dodgerblue4", "dodgerblue1", "firebrick1", "firebrick4")) + | |
| 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(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
| geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "black") + | |
| geom_text(aes(label = ifelse(app == "Strongly Disapprove", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| geom_text(aes(label = ifelse(app == "Strongly Approve", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| theme(plot.title = element_text(size = 16)) + | |
| theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) + | |
| theme(strip.text.x.top = element_text(size = 22)) + | |
| labs(x = "", y = "", title = "Joe Biden's Approval Rating Among Catholics", caption = "@ryanburge\nData: Cooperative Election Study, 2021-2023") | |
| save("biden_app_catholic.png", wd = 9, ht = 6) | |
| gg %>% | |
| filter(trad2 == "Mormon" | trad2 == "Orthodox") %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = fct_rev(year), y = pct, fill = fct_rev(app))) + | |
| geom_col(color = "black") + | |
| coord_flip() + | |
| facet_wrap(~ trad2, ncol =1, strip.position = "top") + | |
| theme_rb() + | |
| scale_fill_manual(values = c("dodgerblue4", "dodgerblue1", "firebrick1", "firebrick4")) + | |
| 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(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
| geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "black") + | |
| geom_text(aes(label = ifelse(app == "Strongly Disapprove", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| geom_text(aes(label = ifelse(app == "Strongly Approve", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| theme(plot.title = element_text(size = 16)) + | |
| theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) + | |
| theme(strip.text.x.top = element_text(size = 22)) + | |
| labs(x = "", y = "", title = "Joe Biden's Approval Rating Among Latter-day Saints and Orthodox Christians", caption = "@ryanburge\nData: Cooperative Election Study, 2021-2023") | |
| save("biden_app_lds_orthodox.png", wd = 9, ht = 6) | |
| gg %>% | |
| filter(trad2 == "Jewish" | trad2 == "Muslim" | trad2 == "Buddhist" | trad2 == "Hindu") %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = fct_rev(year), y = pct, fill = fct_rev(app))) + | |
| geom_col(color = "black") + | |
| coord_flip() + | |
| facet_wrap(~ trad2, ncol =1, strip.position = "top") + | |
| theme_rb() + | |
| scale_fill_manual(values = c("dodgerblue4", "dodgerblue1", "firebrick1", "firebrick4")) + | |
| 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(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
| geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "black") + | |
| geom_text(aes(label = ifelse(app == "Strongly Disapprove", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| geom_text(aes(label = ifelse(app == "Strongly Approve", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| theme(plot.title = element_text(size = 16)) + | |
| theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) + | |
| theme(strip.text.x.top = element_text(size = 22)) + | |
| labs(x = "", y = "", title = "Joe Biden's Approval Rating Among Smaller Religious Groups", caption = "@ryanburge\nData: Cooperative Election Study, 2021-2023") | |
| save("biden_app_world_rel.png", wd = 9, ht = 9) | |
| gg %>% | |
| filter(trad2 == "Atheist" | trad2 == "Agnostic" | trad2 == "Nothing in Particular") %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = fct_rev(year), y = pct, fill = fct_rev(app))) + | |
| geom_col(color = "black") + | |
| coord_flip() + | |
| facet_wrap(~ trad2, ncol =1, strip.position = "top") + | |
| theme_rb() + | |
| scale_fill_manual(values = c("dodgerblue4", "dodgerblue1", "firebrick1", "firebrick4")) + | |
| 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(panel.grid.minor.y=element_blank(), panel.grid.major.y=element_blank()) + | |
| geom_text(aes(label = ifelse(pct >.05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "black") + | |
| geom_text(aes(label = ifelse(app == "Strongly Disapprove", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| geom_text(aes(label = ifelse(app == "Strongly Approve", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 9, family = "font", color = "white") + | |
| theme(plot.title = element_text(size = 16)) + | |
| theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) + | |
| theme(strip.text.x.top = element_text(size = 22)) + | |
| labs(x = "", y = "", title = "Joe Biden's Approval Rating Among Non-Religious Groups", caption = "@ryanburge\nData: Cooperative Election Study, 2021-2023") | |
| save("biden_app_nones.png", wd = 9, ht = 7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment