-
-
Save ryanburge/dbcdb7a753771ecdb4426b4545843106 to your computer and use it in GitHub Desktop.
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
library(rio) | |
library(janitor) | |
clergy <- import("E://data/clergy.sav") %>% clean_names() | |
clergy %>% | |
ct(timeserv) | |
clergy %>% | |
ct(hrcong) | |
good <- clergy %>% | |
mutate(good = lifegood) %>% | |
mutate(good = frcode(good == 1 ~ "Completely\nDisagree", | |
good == 2 ~ "Moderately\nDisagree", | |
good == 3 ~ "Slightly\nDisagree", | |
good == 4 ~ "Neither", | |
good == 5 ~ "Slightly\nAgree", | |
good == 6 ~ "Moderately\nAgree", | |
good == 7 ~ "Completely\nAgree")) %>% | |
ct(good, wt = wt_nsrl_all_attendee, show_na = FALSE) | |
good %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = good, y = pct, fill = good)) + | |
geom_col(color = "black") + | |
theme_rb() + | |
y_pct() + | |
scale_fill_manual(values = c("#033f63", "#28666e", "#e1e1e1", "#B5B682", "#FEDC97", "#7D3C98", "#5f2680")) + | |
geom_text(aes(y = pct + .025, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 9, family = "font") + | |
labs(x = "", y = "", title = "In most ways my life is close to my ideal - Among Clergy", caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2023") | |
save("life_good_clergy.png", wd = 6) | |
good1 <- clergy %>% | |
mutate(sat = satlife) %>% | |
mutate(sat = frcode(sat == 1 ~" Never", | |
sat == 2 ~ "Once or\nTwice", | |
sat == 3 ~ "Weekly", | |
sat == 4 ~ "2-3x\nWeek", | |
sat == 5 ~ "Almost Every\nDay", | |
sat == 6 ~ "Every Day")) %>% | |
ct(sat, wt = wt_nsrl_all_attendee, show_na = FALSE) %>% | |
mutate(type = "Satisified With Life") | |
good2 <- clergy %>% | |
mutate(sat = happy) %>% | |
mutate(sat = frcode(sat == 1 ~" Never", | |
sat == 2 ~ "Once or\nTwice", | |
sat == 3 ~ "Weekly", | |
sat == 4 ~ "2-3x\nWeek", | |
sat == 5 ~ "Almost Every\nDay", | |
sat == 6 ~ "Every Day")) %>% | |
ct(sat, wt = wt_nsrl_all_attendee, show_na = FALSE) %>% | |
mutate(type = "Happy") | |
both <- bind_rows(good1, good2) | |
both %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = sat, y = pct, fill = type)) + | |
geom_col(color = "black", position = "dodge") + | |
theme_rb(legend = TRUE) + | |
y_pct() + | |
scale_fill_manual(values = c("#28666e", "#7D3C98")) + | |
geom_text(aes(y = pct + .02, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 7.5, family = "font") + | |
labs(x = "", y = "", title = "During the Past Month, How Often Do You Feel...? - Among Clergy", caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2023") | |
save("happy_bars_clergy.png", wd = 8) | |
clergy %>% | |
ct(timeserv, cum = TRUE) | |
good <- clergy %>% | |
mutate(time = timeserv) %>% | |
mutate(time = frcode(time < 10 ~ "< 10", | |
time >= 10 & time < 20 ~ "10-20", | |
time >= 20 & time < 30 ~ "20-30", | |
time >= 40 ~ "40+")) %>% | |
mutate(good = lifegood) %>% | |
mutate(good = case_when(good == 6 | good == 7 ~ 1, | |
good <= 5 ~ 0)) %>% | |
group_by(time) %>% | |
mean_ci(good, wt = wt_nsrl_all_attendee, ci = .84) %>% | |
na.omit() | |
good %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = time, y = mean, fill = time)) + | |
geom_col(color = "black") + | |
theme_rb() + | |
y_pct() + | |
scale_fill_manual(values = c("#033f63", "#28666e", "#7D3C98", "#5f2680")) + | |
theme(axis.text.x = element_text(size = 24)) + | |
geom_text(aes(y = mean + .055, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 12, family = "font") + | |
labs(x = "Number of Years in Ministry", y = "Share Saying Mostly/Completely Agree", title = "In most ways my life is close to my ideal - Among Clergy", caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2023") | |
save("life_good_clergy_timeserve.png", wd = 6) | |
clergy %>% | |
ct(hrcong, cum = TRUE) | |
good <- clergy %>% | |
mutate(time = hrcong) %>% | |
mutate(time = frcode(time < 20 ~ "< 20", | |
time >= 20 & time < 40 ~ "20-40", | |
time >= 40 & time < 50 ~ "40-50", | |
time >= 50 ~ "50+")) %>% | |
mutate(good = lifegood) %>% | |
mutate(good = case_when(good == 6 | good == 7 ~ 1, | |
good <= 5 ~ 0)) %>% | |
group_by(time) %>% | |
mean_ci(good, wt = wt_nsrl_all_attendee, ci = .84) %>% | |
na.omit() | |
good %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = time, y = mean, fill = time)) + | |
geom_col(color = "black") + | |
theme_rb() + | |
y_pct() + | |
scale_fill_manual(values = c("#28666e", "#B5B682", "#FEDC97", "#7D3C98")) + | |
theme(axis.text.x = element_text(size = 24)) + | |
geom_text(aes(y = mean + .055, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 12, family = "font") + | |
labs(x = "Number of Hours Worked per Week", y = "Share Saying Mostly/Completely Agree", title = "In most ways my life is close to my ideal - Among Clergy", caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2023") | |
save("life_good_clergy_hours_served.png", wd = 6) | |
gg <- clergy %>% | |
mutate(relig = i_religion) %>% | |
mutate(relig = frcode(relig == 1 ~ "Catholic", | |
relig == 2 ~ "White Evangelical", | |
relig == 3 ~ "Black Protestant", | |
relig == 4 ~ "White Liberal/Moderate", | |
relig == 5 ~ "Non-Christian")) %>% | |
mutate(good = lifegood) %>% | |
mutate(good = case_when(good == 6 | good == 7 ~ 1, | |
good <= 5 ~ 0)) %>% | |
group_by(relig) %>% | |
mean_ci(good, wt = wt_nsrl_all_attendee, ci = .84) %>% | |
na.omit() | |
gg %>% | |
mutate(lab = round(mean, 2)) %>% | |
ggplot(., aes(x = reorder(relig, mean), y = mean, fill = relig)) + | |
geom_col(color = "black") + | |
coord_flip() + | |
theme_rb() + | |
error_bar() + | |
y_pct() + | |
scale_fill_manual(values = c("#033f63", "#28666e", "#B5B682", "#FEDC97", "#7D3C98", "#5f2680")) + | |
lab_bar(top = FALSE, type = lab, pos = .04, sz = 8) + | |
geom_text(aes(y = .04, label = ifelse(relig == "Catholic", paste0(lab*100, '%'), "")), position = position_dodge(width = .9), size = 8, family = "font", color = "white") + | |
geom_text(aes(y = .04, label = ifelse(relig == "White Evangelical", paste0(lab*100, '%'), "")), position = position_dodge(width = .9), size = 8, family = "font", color = "white") + | |
geom_text(aes(y = .04, label = ifelse(relig == "Non-Christian", paste0(lab*100, '%'), "")), position = position_dodge(width = .9), size = 8, family = "font", color = "white") + | |
labs(x = "", y = "Share Saying Mostly/Completely Agree", title = "In most ways my life is close to my ideal - Among Clergy", caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2023") | |
save("relig_life_good.png", ht = 4) | |
reg <- clergy %>% | |
mutate(good = lifegood) %>% | |
mutate(good = case_when(good == 6 | good == 7 ~ 1, | |
good <= 5 ~ 0)) %>% | |
mutate(white = case_when(i_race == 1 ~ 1, | |
TRUE ~ 0)) %>% | |
mutate(male = case_when(i_gender == 1 ~ 1, | |
i_gender == 2 ~ 0)) %>% | |
mutate(cons = case_when(i_politics == 3 ~ 1, | |
i_politics == 2 | i_politics == 1 ~ 0)) %>% | |
mutate(educ = i_educ) %>% | |
mutate(size = cong_size) %>% | |
mutate(income = hhincome) %>% | |
mutate(age = 8 - yearborn) %>% | |
select(good, hrcong, timeserv, white, male, cons, educ, size, income, age) | |
regg <- glm(good ~ hrcong + timeserv + white + male + cons + educ + size + income + age, family = "binomial", data = reg) | |
library(jtools) | |
coef_names <- c("Age" = "age", | |
"Male" = "male", | |
"White" = "white", | |
"Income" = "income", | |
"Conservative" = "cons", | |
"Hours Worked" = "hrcong", | |
"Years in Ministry" = "timeserv", | |
"Education" = "educ", | |
"Size of Cong." = "size") | |
gg1 <- plot_summs(regg, robust = "HC3", scale = TRUE, coefs = coef_names) | |
gg1 + | |
theme_rb() + | |
# add_text(x = -.55, y = 6.5, word = "Less Likely to Switch", sz = 8) + | |
labs(x = "", y = "", title = "What Factors Lead Life Satisfaction for Clergy?", caption = "@ryanburge + @religiondata\nData: National Survey of Religious Leaders, 2023") | |
save("reg_predict_clergy_happy.png", ht = 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment