Skip to content

Instantly share code, notes, and snippets.

@ryanburge
Created April 4, 2025 18:48
Show Gist options
  • Select an option

  • Save ryanburge/e211e4feae1c22d4bf2e09669639b3eb to your computer and use it in GitHub Desktop.

Select an option

Save ryanburge/e211e4feae1c22d4bf2e09669639b3eb to your computer and use it in GitHub Desktop.
library(rio)
library(janitor)
clergy <- import("E://data/clergy.sav") %>% clean_names()
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(god_belief = frcode(
god == 1 ~ "Certain Belief",
god == 2 ~ "Believes w/Doubts",
god == 3 ~ "Sometimes Believes",
god == 4 ~ "Higher Power",
god == 5 ~ "Agnostic",
god == 6 ~ "Atheist")) %>%
group_by(trad) %>%
ct(god_belief, wt = wt_nsrl_all_attendee, show_na = FALSE)
gg %>%
mutate(lab = round(pct, 2)) %>%
ggplot(., aes(x = 1, y = pct, fill = fct_rev(god_belief))) +
geom_col(color = "black") +
coord_flip() +
facet_wrap(~ trad, ncol =1, strip.position = "left") +
theme_rb() +
theme(legend.position = "bottom") +
scale_y_continuous(labels = percent) +
scale_fill_manual(values = c(
"Certain Belief" = "#1B9E77", # Teal
"Believes w/Doubts" = "#A6761D", # Bronze
"Sometimes Believes" = "#FFD92F", # Vivid yellow
"Higher Power" = "#E7298A", # Hot pink
"Agnostic" = "#66C2A5", # Soft aqua
"Atheist" = "#7570B3" # Rich purple
)) +
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 = "Which statement comes closest to expressing what you believe about God?",
caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020")
save("clergy_belief_reltrad.png", wd = 9, ht = 4.5)
gg1 <- clergy %>%
mutate(cc = hell) %>%
mutate(cc = case_when(cc == 5 ~ 1,
cc <= 4 ~ 0)) %>%
mutate(trad = cong_trad) %>%
mutate(trad = frcode(trad == 1 ~ "Catholic",
trad == 2 ~ "Evangelical",
trad == 3 ~ "Black Protestant",
trad == 4 ~ "Mainline",
trad == 6 ~ "Non-Christian")) %>%
group_by(trad) %>%
mean_ci(cc, wt = wt_nsrl_all_attendee, ci = .84) %>%
mutate(type = "Hell")
gg2 <- clergy %>%
mutate(cc = miraheal) %>%
mutate(cc = case_when(cc == 5 ~ 1,
cc <= 4 ~ 0)) %>%
mutate(trad = cong_trad) %>%
mutate(trad = frcode(trad == 1 ~ "Catholic",
trad == 2 ~ "Evangelical",
trad == 3 ~ "Black Protestant",
trad == 4 ~ "Mainline",
trad == 6 ~ "Non-Christian")) %>%
group_by(trad) %>%
mean_ci(cc, wt = wt_nsrl_all_attendee, ci = .84) %>%
mutate(type = "Miraculous Healing")
gg3 <- clergy %>%
mutate(cc = reincar) %>%
mutate(cc = case_when(cc == 5 ~ 1,
cc <= 4 ~ 0)) %>%
mutate(trad = cong_trad) %>%
mutate(trad = frcode(trad == 1 ~ "Catholic",
trad == 2 ~ "Evangelical",
trad == 3 ~ "Black Protestant",
trad == 4 ~ "Mainline",
trad == 6 ~ "Non-Christian")) %>%
group_by(trad) %>%
mean_ci(cc, wt = wt_nsrl_all_attendee, ci = .84) %>%
mutate(type = "Physical Reincarnation")
gg4 <- clergy %>%
mutate(cc = astrol) %>%
mutate(cc = case_when(cc == 5 ~ 1,
cc <= 4 ~ 0)) %>%
mutate(trad = cong_trad) %>%
mutate(trad = frcode(trad == 1 ~ "Catholic",
trad == 2 ~ "Evangelical",
trad == 3 ~ "Black Protestant",
trad == 4 ~ "Mainline",
trad == 6 ~ "Non-Christian")) %>%
group_by(trad) %>%
mean_ci(cc, wt = wt_nsrl_all_attendee, ci = .84) %>%
mutate(type = "Astrology")
gg5 <- clergy %>%
mutate(cc = resurect) %>%
mutate(cc = case_when(cc == 5 ~ 1,
cc <= 4 ~ 0)) %>%
mutate(trad = cong_trad) %>%
mutate(trad = frcode(trad == 1 ~ "Catholic",
trad == 2 ~ "Evangelical",
trad == 3 ~ "Black Protestant",
trad == 4 ~ "Mainline",
trad == 6 ~ "Non-Christian")) %>%
group_by(trad) %>%
mean_ci(cc, wt = wt_nsrl_all_attendee, ci = .84) %>%
mutate(type = "Jesus's Bodily Resurrection") %>%
na.omit()
gg6 <- clergy %>%
mutate(cc = adameve) %>%
mutate(cc = case_when(cc == 5 ~ 1,
cc <= 4 ~ 0)) %>%
mutate(trad = cong_trad) %>%
mutate(trad = frcode(trad == 1 ~ "Catholic",
trad == 2 ~ "Evangelical",
trad == 3 ~ "Black Protestant",
trad == 4 ~ "Mainline",
trad == 6 ~ "Non-Christian")) %>%
group_by(trad) %>%
mean_ci(cc, wt = wt_nsrl_all_attendee, ci = .84) %>%
mutate(type = "Adam and Eve Existed") %>%
na.omit()
all <- bind_rows(gg1, gg2, gg3, gg4, gg5, gg6)
all %>%
ggplot(., aes(x = fct_rev(trad), y = mean, fill = trad)) +
geom_col(color = 'black') +
coord_flip() +
facet_wrap(~ type) +
theme_rb() +
y_pct() +
scale_fill_manual(values = c(
"Catholic" = "#E69F00", # orange
"Evangelical" = "#56B4E9", # sky blue
"Black Protestant"= "#009E73", # green
"Mainline" = "#F0E442", # yellow
"Non-Christian" = "#CC79A7" # pink/magenta
)) +
lab_bar(above = TRUE, pos = .12, sz = 7, type = mean) +
labs(x = "", y = "", title = "Share of Clergy Who Definitely Believe in the Following...", caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020")
save("survey_rel_leaders_belief_items.png", wd = 10)
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(bible = frcode(bible == 1 ~ "Literal Word of God",
bible == 2 ~ "Inspired, Without Errors",
bible == 3 ~ "Inspired, Not Historically Accurate",
bible == 4 | bible == 5 ~ "Something Else")) %>%
group_by(trad) %>%
ct(bible, wt = wt_nsrl_all_attendee, show_na = FALSE)
gg %>%
mutate(lab = round(pct, 2)) %>%
ggplot(., aes(x = 1, y = pct, fill = fct_rev(bible))) +
geom_col(color = "black") +
coord_flip() +
facet_wrap(~ trad, ncol =1, strip.position = "left") +
theme_rb() +
theme(legend.position = "bottom") +
theme(legend.text = element_text(lineheight = 1.1)) +
scale_y_continuous(labels = percent) +
scale_fill_manual(values = c(
"Literal Word of God" = "#6A0DAD", # Amethyst (vibrant purple)
"Inspired, Without Errors" = "#FF8C00", # Dark orange
"Inspired, Not Historically Accurate" = "#FFD700", # Gold
"Something Else" = "#7CFC00", # Lawn green
"Stories, Legends - Little Relevance Today" = "#DA70D6" # Orchid
)) +
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(bible == "Literal Word of God" & pct > .05, paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, 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 = "Which of the following comes closest to your personal beliefs about the Bible?",
caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020")
save("clergy_belief_bible_reltrad.png", wd = 9, ht = 4)
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(best = minebest) %>%
mutate(best = frcode(best == 1 | best == 2 | best == 3 ~ "Disagree",
best == 4 ~ "Neither Agree nor Disagree",
best == 5 | best == 6 | best == 7 ~ "Agree")) %>%
group_by(trad) %>%
ct(best, wt_nsrl_all_attendee, show_na = FALSE)
gg %>%
mutate(lab = round(pct, 2)) %>%
ggplot(., aes(x = 1, y = pct, fill = fct_rev(best))) +
geom_col(color = "black") +
coord_flip() +
facet_wrap(~ trad, ncol =1, strip.position = "left") +
theme_rb() +
theme(legend.position = "bottom") +
theme(legend.text = element_text(lineheight = 1.1)) +
scale_y_continuous(labels = percent) +
scale_fill_manual(values = c(
"Disagree" = "#D3D3D3", # Light gray
"Neither Agree nor Disagree" = "#FDB863", # Warm amber
"Agree" = "#5E3C99" # Rich purple
)) +
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(best == "Agree", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, 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 = 14)) +
theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) +
labs(x = "", y = "", title = "My religion would be the best one for all people no matter their background or current religion.",
caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020")
save("clergy_mine_best.png", wd = 9, ht = 4)
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(best = convert) %>%
mutate(best = frcode(best == 1 | best == 2 | best == 3 ~ "Disagree",
best == 4 ~ "Neither Agree nor Disagree",
best == 5 | best == 6 | best == 7 ~ "Agree")) %>%
group_by(trad) %>%
ct(best, wt_nsrl_all_attendee, show_na = FALSE)
gg %>%
mutate(lab = round(pct, 2)) %>%
ggplot(., aes(x = 1, y = pct, fill = fct_rev(best))) +
geom_col(color = "black") +
coord_flip() +
facet_wrap(~ trad, ncol =1, strip.position = "left") +
theme_rb() +
theme(legend.position = "bottom") +
theme(legend.text = element_text(lineheight = 1.1)) +
scale_y_continuous(labels = percent) +
scale_fill_manual(values = c(
"Disagree" = "#D3D3D3", # Light gray
"Neither Agree nor Disagree" = "#FDB863", # Warm amber
"Agree" = "#5E3C99" # Rich purple
)) +
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(best == "Agree", paste0(lab*100, '%'), '')), position = position_stack(vjust = 0.5), size = 8, 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 = 12)) +
theme(strip.text.y.left = element_text(angle = 0, hjust = 1)) +
labs(x = "", y = "", title = "It is important for me to try to persuade people in other religions to accept my religion instead of their own.",
caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2019-2020")
save("clergy_try_convert.png", wd = 9, ht = 4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment