-
-
Save ryanburge/48d464d4183760d5e1205a9fa0262410 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
gg1 <- gss %>% | |
filter(year <= 2018) %>% | |
mutate(belief = case_when(god == 1 | god == 2 ~ 1, | |
god == 3 | god == 4 | god == 5 | god == 6 ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(belief, wt = wtssall, ci = .84) %>% | |
na.omit() | |
gg2 <- gss %>% | |
filter(year > 2018) %>% | |
mutate(belief = case_when(god == 1 | god == 2 ~ 1, | |
god == 3 | god == 4 | god == 5 | god == 6 ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(belief, wt = wtssnrps, ci = .84) %>% | |
na.omit() | |
bel <- bind_rows(gg1, gg2) %>% mutate(type = "Belief") | |
gg1 <- gss %>% | |
filter(year <= 2018) %>% | |
mutate(never = case_when(attend == 0 ~ 1, | |
attend <= 8 ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(never, wt = wtssall, ci = .84) %>% | |
na.omit() | |
gg2 <- gss %>% | |
filter(year > 2018) %>% | |
mutate(never = case_when(attend == 0 ~ 1, | |
attend <= 8 ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(never, wt = wtssnrps, ci = .84) %>% | |
na.omit() | |
att <- bind_rows(gg1, gg2) %>% mutate(type = "Behavior") | |
gg1 <- gss %>% | |
filter(year <= 2018) %>% | |
mutate(none = case_when(relig == 4 ~ 1, | |
TRUE ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(none, wt = wtssall, ci = .84) %>% | |
na.omit() | |
gg2 <- gss %>% | |
filter(year > 2018) %>% | |
mutate(none = case_when(relig == 4 ~ 1, | |
TRUE ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(none, wt = wtssnrps, ci = .84) %>% | |
na.omit() | |
belong <- bind_rows(gg1, gg2)%>% mutate(type = "Belonging") | |
gg <- bind_rows(bel, att, belong) | |
gg %>% | |
ggplot(., aes(x = year, y = mean, color = type, group = type)) + | |
geom_line() + | |
geom_point(stroke = .75, shape = 21, fill = "white") + | |
scale_y_continuous(labels = percent, limits = c(0, .35)) + | |
theme_rb() + | |
annotate("text", x = 2013, y = .06, label ="Don't Believe", size = 8, family = "font", color = "#00b259") + | |
annotate("text", x = 2014, y = .16, label = "Don't Belong", size = 8, family = "font", color = "#35a7ff") + | |
annotate("text", x = 2012, y = .29, label = "Don't Behave", size = 8, family = "font", color = "#ff5964") + | |
scale_color_manual(values = c("#ff5964", "#00b259", "#35a7ff")) + | |
labs(x = "Year", y = "", title = "Behavior, Belief, and Belonging in American Religion", caption = "@ryanburge\nData: General Social Survey, 1972-2022") | |
save("gss_behavior_belief_belong22.png") | |
one <- gss %>% | |
filter(year >= 1988) %>% | |
filter(year <= 2018) %>% | |
mutate(belief = case_when(god == 1 | god == 2 ~ 1, | |
god == 3 | god == 4 | god == 5 | god == 6 ~ 0)) %>% | |
mutate(never = case_when(attend == 0 ~ 1, | |
attend <= 8 ~ 0)) %>% | |
mutate(none = case_when(relig == 4 ~ 1, | |
TRUE ~ 0)) %>% | |
mutate(all = belief + never + none) %>% | |
mutate(all = case_when(all == 3 ~ 1, | |
all == 0 | all == 1 | all == 2 ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(all, wt = wtssall, ci = .84) | |
two <- gss %>% | |
filter(year > 2018) %>% | |
mutate(belief = case_when(god == 1 | god == 2 ~ 1, | |
god == 3 | god == 4 | god == 5 | god == 6 ~ 0)) %>% | |
mutate(never = case_when(attend == 0 ~ 1, | |
attend <= 8 ~ 0)) %>% | |
mutate(none = case_when(relig == 4 ~ 1, | |
TRUE ~ 0)) %>% | |
mutate(all = belief + never + none) %>% | |
mutate(all = case_when(all == 3 ~ 1, | |
all == 0 | all == 1 | all == 2 ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(all, wt = wtssnrps, ci = .84) | |
both <- bind_rows(one, two) | |
both %>% | |
mutate(lab = round(mean,3)) %>% | |
mutate(year = as.factor(year)) %>% | |
filter(mean > 0) %>% | |
ggplot(., aes(x = year, y = mean, fill = mean)) + | |
geom_col(color = "black") + | |
theme_rb() + | |
scale_fill_gradient(low = "#FFA17F", high = "#00223E") + | |
scale_y_continuous(labels = percent) + | |
geom_text(aes(y = mean + .0035, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 6, family = "font") + | |
labs(x = "", y = "", title = "Share Who Are Non-Religious on All Three Dimensions", caption = "@ryanburge\nData: General Social Survey, 1988-2022") | |
save("all_nones22.png") | |
one <- gss %>% | |
filter(year >= 1988) %>% | |
filter(year <= 2018) %>% | |
mutate(belief = case_when(god == 6 ~ 1, | |
god == 2 | god == 3 | god == 4 | god == 5 | god == 1 ~ 0)) %>% | |
mutate(never = case_when(attend == 6 | attend == 7 | attend == 8 ~ 1, | |
attend <= 5 ~ 0)) %>% | |
mutate(none = case_when(relig == 1 | relig == 2 | relig == 3 | relig == 5 | relig == 6 | relig == 7 | relig == 8 | relig == 9 | relig == 10 | relig == 11 | relig == 12 | relig == 13 ~ 1, | |
relig == 4 ~ 0)) %>% | |
mutate(all = belief + never + none) %>% | |
mutate(all = case_when(all == 3 ~ 1, | |
all == 0 | all == 1 | all == 2 ~ 0)) %>% | |
filter(all != 'NA') %>% | |
group_by(year) %>% | |
mean_ci(all, wt = wtssall, ci = .84) | |
two <- gss %>% | |
filter(year > 2018) %>% | |
mutate(belief = case_when(god == 6 ~ 1, | |
god == 2 | god == 3 | god == 4 | god == 5 | god == 1 ~ 0)) %>% | |
mutate(never = case_when(attend == 6 | attend == 7 | attend == 8 ~ 1, | |
attend <= 5 ~ 0)) %>% | |
mutate(none = case_when(relig == 1 | relig == 2 | relig == 3 | relig == 5 | relig == 6 | relig == 7 | relig == 8 | relig == 9 | relig == 10 | relig == 11 | relig == 12 | relig == 13 ~ 1, | |
relig == 4 ~ 0)) %>% | |
mutate(all = belief + never + none) %>% | |
mutate(all = case_when(all == 3 ~ 1, | |
all == 0 | all == 1 | all == 2 ~ 0)) %>% | |
group_by(year) %>% | |
mean_ci(all, wt = wtssnrps, ci = .84) | |
both <- bind_rows(one, two) | |
both %>% | |
mutate(lab = round(mean,2)) %>% | |
mutate(year = as.factor(year)) %>% | |
filter(mean > 0) %>% | |
ggplot(., aes(x = year, y = mean, fill = mean)) + | |
geom_col(color = "black") + | |
theme_rb() + | |
scale_fill_gradient(low = "#F1F2B5", high = "#135058") + | |
scale_y_continuous(labels = percent) + | |
geom_text(aes(y = mean + .01, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 6, family = "font") + | |
labs(x = "", y = "", title = "Share Who Are Religious on All Three Dimensions", caption = "@ryanburge\nData: General Social Survey, 1988-2022") | |
save("no_nones22.png") | |
gg <- gss %>% | |
filter(year == 2022) %>% | |
filter(attend == 0) %>% | |
mutate(gd = frcode(god == 1 ~ "Don't Believe", | |
god == 2 ~ "No Way to Find Out", | |
god == 3 ~ "Some Higher Power", | |
god == 4 ~ "Believe Sometimes", | |
god == 5 ~ "Believe But Doubts", | |
god == 6 ~ "Believe No Doubts")) %>% | |
ct(gd, wt = wtssnrps, show_na = FALSE) | |
gg %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = fct_rev(gd), y = pct, fill = gd)) + | |
geom_col(color = "black") + | |
coord_flip() + | |
y_pct() + | |
scale_fill_paletteer_d("ggthemes::Classic_Blue_Red_6")+ | |
geom_text(aes(y = pct + .012, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 8, family = "font") + | |
theme_rb() + | |
labs(x = "", y = "", title = "What Do You Believe About God? Among Those Who Never Attend Services", caption = "@ryanburge\nData: General Social Survey, 2022") | |
save("never_att_belief22.png", ht = 4) | |
ttt1 <- gss %>% | |
filter(year == 2021) %>% | |
filter(norelgsp == 1) %>% | |
mutate(gd = frcode(god == 1 ~ "Don't Believe", | |
god == 2 ~ "No Way to Find Out", | |
god == 3 ~ "Some Higher Power", | |
god == 4 ~ "Believe Sometimes", | |
god == 5 ~ "Believe But Doubts", | |
god == 6 ~ "Believe No Doubts")) %>% | |
ct(gd, wt = wtssnrps, show_na = FALSE) %>% | |
mutate(type = "Atheist") | |
ttt2 <- gss %>% | |
filter(year == 2021) %>% | |
filter(norelgsp == 2) %>% | |
mutate(gd = frcode(god == 1 ~ "Don't Believe", | |
god == 2 ~ "No Way to Find Out", | |
god == 3 ~ "Some Higher Power", | |
god == 4 ~ "Believe Sometimes", | |
god == 5 ~ "Believe But Doubts", | |
god == 6 ~ "Believe No Doubts")) %>% | |
ct(gd, wt = wtssnrps, show_na = FALSE) %>% | |
mutate(type = "Agnostic") | |
ttt3 <- gss %>% | |
filter(year == 2021) %>% | |
filter(norelgsp == 4) %>% | |
mutate(gd = frcode(god == 1 ~ "Don't Believe", | |
god == 2 ~ "No Way to Find Out", | |
god == 3 ~ "Some Higher Power", | |
god == 4 ~ "Believe Sometimes", | |
god == 5 ~ "Believe But Doubts", | |
god == 6 ~ "Believe No Doubts")) %>% | |
ct(gd, wt = wtssnrps, show_na = FALSE) %>% | |
mutate(type = "Nothing in Particular") | |
all <- bind_rows(ttt1, ttt2, ttt3) | |
all$type <- factor(all$type, levels = c("Atheist", "Agnostic", "Nothing in Particular")) | |
all %>% | |
mutate(lab = round(pct, 2)) %>% | |
ggplot(., aes(x = gd, y = pct, fill = gd)) + | |
geom_col(color = "black") + | |
facet_wrap(~ type) + | |
coord_flip() + | |
theme_rb() + | |
y_pct() + | |
scale_fill_manual(values = c(moma.colors("Panton", 6))) + | |
geom_text(aes(y = pct + .0525, label = paste0(lab*100, '%')), position = position_dodge(width = .9), size = 5, family = "font") + | |
labs(x = "", y = "", title = "Beliefs about God Among Those with No Religious Affiliation", caption = "@ryanburge\nData: General Social Survey, 2021") | |
save("gss21_god_belief.png", wd = 11, ht = 4) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment