-
-
Save ryanburge/4102aa449d76956e77d1f4df976c5bd8 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
| library(rio) | |
| library(janitor) | |
| clergy <- import("E://data/clergy.sav") %>% clean_names() | |
| gg <- clergy %>% | |
| mutate(gm = frcode( | |
| gaymarry == 1 ~ "Definitely\nnot", | |
| gaymarry == 2 ~ "Probably\nnot", | |
| gaymarry == 3 ~ "Not\nsure", | |
| gaymarry == 4 ~ "Probably\nyes", | |
| gaymarry == 5 ~ "Definitely\nyes" | |
| )) %>% | |
| ct(gm, wt = wt_nsrl_all_attendee, show_na = FALSE) | |
| gg %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = gm, y = pct, fill = gm)) + | |
| geom_col(color = 'black') + | |
| theme_rb() + | |
| y_pct() + | |
| scale_fill_manual(values = c( | |
| "Definitely\nnot" = "#d73027", | |
| "Probably\nnot" = "#fc8d59", | |
| "Not\nsure" = "#fee08b", | |
| "Probably\nyes" = "#91bfdb", | |
| "Definitely\nyes" = "#4575b4", | |
| "Not\ncredentialed" = "#cccccc" | |
| )) + | |
| geom_text(aes(y = pct + .035, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 10, family = "font") + | |
| labs(x = "", y = "", title = "Would you perform the wedding of a same-sex\ncouple if your religious group allowed it?", | |
| caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020") | |
| save("clergy_gay_marry.png", wd = 5) | |
| gg <- clergy %>% | |
| mutate(gm = frcode( | |
| gaymarry == 1 ~ "Definitely not", | |
| gaymarry == 2 ~ "Probably not", | |
| gaymarry == 3 ~ "Not sure", | |
| gaymarry == 4 ~ "Probably yes", | |
| gaymarry == 5 ~ "Definitely yes" | |
| )) %>% | |
| mutate(id3 = frcode( | |
| polviews %in% c(1, 2, 3) ~ "Liberal", | |
| polviews == 4 ~ "Moderate", | |
| polviews %in% c(5, 6, 7) ~ "Conservative" | |
| )) %>% | |
| group_by(id3) %>% | |
| ct(gm, wt = wt_nsrl_all_attendee, show_na = FALSE) %>% | |
| na.omit() | |
| gg %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = 1, y = pct, fill = fct_rev(gm))) + | |
| geom_col(color = "black") + | |
| coord_flip() + | |
| facet_wrap(~ id3, ncol =1, strip.position = "left") + | |
| theme_rb() + | |
| scale_fill_manual(values = c( | |
| "Definitely not" = "#d73027", | |
| "Probably not" = "#fc8d59", | |
| "Not sure" = "#fee08b", | |
| "Probably yes" = "#91bfdb", | |
| "Definitely yes" = "#4575b4", | |
| "Not credentialed" = "#cccccc" | |
| )) + 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(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 10, family = "font", color = "black") + | |
| # geom_text(aes(label = ifelse(age2 == "18-35", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "white") + | |
| # geom_text(aes(label = ifelse(age2 == "36-44", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "white") + | |
| theme(plot.title = element_text(size = 16)) + | |
| theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) + | |
| labs(x = "", y = "", title = "Would you perform the wedding of a same-sex couple if your religious group allowed it?", | |
| caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020") | |
| save("clergy_wedding_id3.png", wd = 9, ht = 3.5) | |
| gg <- clergy %>% | |
| mutate(talk = frcode(actlgbt == 1 ~ "Addressed LBGT Issues", | |
| actlgbt == 2 ~ "Did Not Address")) %>% | |
| mutate(gm = frcode( | |
| gaymarry == 1 ~ "Definitely not", | |
| gaymarry == 2 ~ "Probably not", | |
| gaymarry == 3 ~ "Not sure", | |
| gaymarry == 4 ~ "Probably yes", | |
| gaymarry == 5 ~ "Definitely yes" | |
| )) %>% | |
| group_by(talk) %>% | |
| ct(gm, wt = wt_nsrl_all_attendee, show_na = FALSE) %>% | |
| na.omit() | |
| gg %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = 1, y = pct, fill = fct_rev(gm))) + | |
| geom_col(color = "black") + | |
| coord_flip() + | |
| facet_wrap(~ talk, ncol =1, strip.position = "left") + | |
| theme_rb() + | |
| scale_fill_manual(values = c( | |
| "Definitely not" = "#d73027", | |
| "Probably not" = "#fc8d59", | |
| "Not sure" = "#fee08b", | |
| "Probably yes" = "#91bfdb", | |
| "Definitely yes" = "#4575b4", | |
| "Not credentialed" = "#cccccc" | |
| )) + 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(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, family = "font", color = "black") + | |
| # geom_text(aes(label = ifelse(age2 == "18-35", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "white") + | |
| # geom_text(aes(label = ifelse(age2 == "36-44", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "white") + | |
| theme(plot.title = element_text(size = 16)) + | |
| theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) + | |
| labs(x = "", y = "", title = "Would you perform the wedding of a same-sex couple if your religious group allowed it?\nBased on Whether The Clergy Engaged in Any Political Advocacy Related To LGBTQ", | |
| caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020") | |
| save("clergy_wedding_address_issue.png", wd = 9, ht = 3) | |
| gg <- clergy %>% | |
| mutate(trad = cong_trad) %>% | |
| mutate(trad = frcode(trad == 1 ~ "Catholic", | |
| trad == 2 ~ "Evangelical", | |
| trad == 3 ~ "Black Protestant", | |
| trad == 4 ~ "Mainline", | |
| trad == 6 ~ "Non-Christian")) %>% | |
| mutate(gm = frcode( | |
| gaymarry == 1 ~ "Definitely not", | |
| gaymarry == 2 ~ "Probably not", | |
| gaymarry == 3 ~ "Not sure", | |
| gaymarry == 4 ~ "Probably yes", | |
| gaymarry == 5 ~ "Definitely yes" | |
| )) %>% | |
| group_by(trad) %>% | |
| ct(gm, wt = wt_nsrl_all_attendee, show_na = FALSE) %>% | |
| na.omit() | |
| gg %>% | |
| mutate(lab = round(pct, 2)) %>% | |
| ggplot(., aes(x = 1, y = pct, fill = fct_rev(gm))) + | |
| geom_col(color = "black") + | |
| coord_flip() + | |
| facet_wrap(~ trad, ncol =1, strip.position = "left") + | |
| theme_rb() + | |
| scale_fill_manual(values = c( | |
| "Definitely not" = "#d73027", | |
| "Probably not" = "#fc8d59", | |
| "Not sure" = "#fee08b", | |
| "Probably yes" = "#91bfdb", | |
| "Definitely yes" = "#4575b4", | |
| "Not credentialed" = "#cccccc" | |
| )) + | |
| 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(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, family = "font", color = "black") + | |
| # geom_text(aes(label = ifelse(age2 == "18-35", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "white") + | |
| # geom_text(aes(label = ifelse(age2 == "36-44", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 4, family = "font", color = "white") + | |
| theme(plot.title = element_text(size = 16)) + | |
| theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) + | |
| labs(x = "", y = "", title = "Would you perform the wedding of a same-sex couple if your religious group allowed it?\nBased on Religious Tradition of Clergy", | |
| caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020") | |
| save("clergy_wedding_reltrad.png", wd = 9, ht = 4.5) | |
| gg <- clergy %>% | |
| mutate(age = frcode( | |
| yearborn == 1 ~ "1930\nto\n1939", | |
| yearborn == 2 ~ "1940\nto\n1949", | |
| yearborn == 3 ~ "1950\nto\n1959", | |
| yearborn == 4 ~ "1960\nto\n1969", | |
| yearborn == 5 ~ "1970\nto\n1979", | |
| yearborn == 6 ~ "1980\nto\n1989", | |
| yearborn == 7 ~ "1990\nto\n1999" | |
| )) %>% | |
| mutate(gm = case_when(gaymarry == 1 ~ 1, | |
| gaymarry <= 5 ~ 0)) %>% | |
| group_by(age) %>% | |
| mean_ci(gm, wt = wt_nsrl_all_attendee, ci = .84) %>% | |
| na.omit() | |
| gg %>% | |
| mutate(lab = round(mean, 2)) %>% | |
| ggplot(., aes(x = age, y = mean, fill = age)) + | |
| geom_col(color = "black") + | |
| theme_rb() + | |
| error_bar() + | |
| y_pct() + | |
| scale_fill_manual(values = c( | |
| "1930\nto\n1939" = "#6a3d9a", # Dark purple | |
| "1940\nto\n1949" = "#1f78b4", # Blue | |
| "1950\nto\n1959" = "#33a02c", # Green | |
| "1960\nto\n1969" = "#b2df8a", # Light green | |
| "1970\nto\n1979" = "#ff7f00", # Orange | |
| "1980\nto\n1989" = "#e31a1c", # Red | |
| "1990\nto\n1999" = "#fb9a99" # Light red/pink | |
| )) + | |
| lab_bar(top = FALSE, type = lab, pos = .05, sz = 8) + | |
| theme(plot.title = element_text(size = 14)) + | |
| labs(x = "Decade of Birth", y = "", title = "Share Who Would Definitely Not Perform a Same-Sex Wedding", | |
| caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020") | |
| save("gay_marriage_age_clergy.png", wd = 5.5) | |
| regg <- clergy %>% | |
| mutate(trad = cong_trad) %>% | |
| filter(trad == 1 | trad == 2 | trad == 3) %>% | |
| mutate(gm = case_when(gaymarry == 4 | gaymarry == 5 ~ 1, | |
| gaymarry <= 3 ~ 0)) %>% | |
| mutate(age = 8- yearborn) %>% | |
| mutate(educ = educ) %>% | |
| mutate(white = case_when(i_race == 1 ~ 1, | |
| TRUE ~ 0)) %>% | |
| mutate(lib = case_when(i_politics == 1 ~ 1, | |
| i_politics == 2 | i_politics == 3 ~ 0)) %>% | |
| mutate(income = i_income) %>% | |
| mutate(male = case_when(i_gender == 1 ~ 1, | |
| i_gender == 2 ~ 0)) %>% | |
| mutate(size = cong_size) %>% | |
| mutate(south = case_when(cong_region == 3 ~ 1, | |
| TRUE ~ 0)) %>% | |
| select(gm, age, educ, white, lib, income, male, size, south) | |
| out <- glm(gm ~ ., data = regg, family = "binomial") | |
| library(jtools) | |
| summ(out) | |
| coef_names <- c("White" = "white", | |
| "Education" = "educ", | |
| "Age" = "age", | |
| "Male" = "male", | |
| "Income" = "income", | |
| "Congregation Size" = "size", | |
| "South" = "south", | |
| "Politically Liberal" = "lib") | |
| out <- plot_summs(out, scale = TRUE, robust = "HC3", colors = "firebrick3", coefs = coef_names) | |
| out + | |
| theme_rb() + | |
| labs(x = "", y = "", title = "What Factors Predict Clergy in Conservative Traditions Conducting LGBT Weddings?", | |
| caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020") | |
| # add_text(x = -9, y = 3.5, word = "Lower Fear Index", sz = 6) | |
| save("lgbt_clergy_summs.png", ht = 4, wd = 9.5) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment