Skip to content

Instantly share code, notes, and snippets.

@acbass49
Last active March 20, 2026 11:03
Show Gist options
  • Select an option

  • Save acbass49/77c6d6c81779818555c6a9598ff2820e to your computer and use it in GitHub Desktop.

Select an option

Save acbass49/77c6d6c81779818555c6a9598ff2820e to your computer and use it in GitHub Desktop.
Are LDS Beating Secular Headwinds
library(tidyverse)
library(binom)
library(haven)
library(car)
library(ggtext)
library(sjlabelled)
library(clipr)
### Starting with CES DATA
# Load the dataset
data <- readRDS("./data/CES/cumulative_2006-2024.rds")
data$relig_church_rc <- car::recode(as.numeric(data$relig_church),"1:2 = 'Weekly or More'; 3:7 = 'Less than Weekly'")
data$relig_church_rc <- factor(data$relig_church_rc,
levels = c("Weekly or More", "Less than Weekly"))
data$relig_church_rc2 <- car::recode(as.numeric(data$relig_church),"1:3 = 'Monthly or More'; 4:7 = 'Less than Monthly'")
data$relig_church_rc2 <- factor(data$relig_church_rc2,
levels = c("Monthly or More", "Less than Monthly"))
# prayer was not in the cumulative file, so I need to merge it in
# I went through each year and added the prayer variable manually.
data <- data |>
mutate(id = paste0(year, "X", case_id)) |>
left_join(read.csv("./data/CES/prayer.csv"), by = "id") |>
mutate(year = year.x)
data <- data |>
mutate(
prayer_rc = case_when(
prayer == 1 ~ "Several Times a Day",
prayer %in% 2:7 ~ "Less Than Several Times a Day",
TRUE ~ NA_character_
),
prayer_rc2 = case_when(
prayer %in% 1:2 ~ "Daily or More",
prayer %in% 3:7 ~ "Less Than Daily",
TRUE ~ NA_character_
)
)
data$relig_imp_rc <- car::recode(as.numeric(data$relig_imp),"1 = 'Very Important'; 2:4 = 'Not Very Important'")
data$relig_imp_rc2 <- car::recode(as.numeric(data$relig_imp),"1:2 = 'Very/somewhat Important'; 3:4 = 'Not Very/somewhat Important'")
data$religion_rc <- dplyr::case_when(
data$religion == 1 & data$relig_bornagain == 1 ~ "Evangelical",
data$religion == 1 & data$relig_bornagain == 2 ~ "Mainline",
data$religion == 3 ~ "Latter-day Saint",
data$religion == 2 ~ "Catholic",
TRUE ~ NA_character_
)
data$religion_rc2 <- dplyr::case_when(
data$religion == 1 & data$relig_bornagain == 1 ~ "Evangelical",
data$religion == 1 & data$relig_bornagain == 2 ~ "Mainline",
data$religion == 3 ~ "Latter-day Saint",
data$religion == 2 ~ "Catholic",
TRUE ~ "Other Religion"
)
# Keeping every protestant denomination with over 10k respondents for the CES
data$religion_rc_new1 <- dplyr::case_when(
data$religion == 1 & data$relig_protestant == 1 ~ "Baptist",
data$religion == 1 & data$relig_protestant == 2 ~ "Methodist",
data$religion == 1 & data$relig_protestant == 3 ~ "Non-Denominational",
data$religion == 1 & data$relig_protestant == 4 ~ "Lutheran",
data$religion == 1 & data$relig_protestant == 5 ~ "Presbyterian",
data$religion == 1 & data$relig_protestant == 7 ~ "Episcopalian",
data$religion == 1 & data$relig_protestant %in% c(6,8:99) ~ "Other Protestant",
data$religion == 3 ~ "Latter-day Saint",
data$religion == 2 ~ "Catholic",
TRUE ~ NA_character_
)
data$religion_rc_new2 <- dplyr::case_when(
data$religion == 1 & data$relig_protestant == 1 ~ "Baptist",
data$religion == 1 & data$relig_protestant == 2 ~ "Methodist",
data$religion == 1 & data$relig_protestant == 3 ~ "Non-Denominational",
data$religion == 1 & data$relig_protestant == 4 ~ "Lutheran",
data$religion == 1 & data$relig_protestant == 5 ~ "Presbyterian",
data$religion == 1 & data$relig_protestant == 7 ~ "Episcopalian",
data$religion == 1 & data$relig_protestant %in% c(6,8:99) ~ "Other Protestant",
data$religion == 3 ~ "Latter-day Saint",
data$religion == 2 ~ "Catholic",
TRUE ~ "Other Religion"
)
tbl1 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc) |>
count(relig_church_rc, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_church_rc == "Weekly or More") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Weekly Church Attendance',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl2 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc) |>
count(relig_church_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_church_rc2 == "Monthly or More") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Monthly Church Attendance',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl3 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc) |>
count(prayer_rc, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(prayer_rc == "Several Times a Day") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Several Times A Day Prayer',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl4 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc) |>
count(prayer_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(prayer_rc2 == "Daily or More") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Daily or More Prayer',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl5 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc) |>
count(relig_imp_rc, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_imp_rc == "Very Important") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Religion is Very Important',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl6 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc) |>
count(relig_imp_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_imp_rc2 == "Very/somewhat Important") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Religion is Very/Somewhat Important',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl7 <- data |>
filter(year > 2008) |>
group_by(year) |>
count(religion_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
select(year, religion_rc2, prop) |>
pivot_wider(names_from = religion_rc2, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) / first(.) * 100)) |>
mutate(
metric = '% Change In US Population',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
### Now Turning to PEW RL Data
data07 <- haven::read_sav("./data/rls/rls2007.sav")
data14 <- haven::read_sav("./data/rls/rls2014.sav")
data24 <- haven::read_sav("./data/rls/rls2024.sav")
data14$weight <- data14$WEIGHT
data24$weight <- data24$WEIGHT
list_to_it <- list(
"Prayer_Frequency" = list('2007' = "q41", '2014' = "qi1", '2024' = "PRAY"),
"Church_Education" = list('2007' = "q42a", '2014' = "qi2a", '2024' = "PRAC_A"),
"Scriptures" = list('2007' = "q42b", '2014' = "qi2b", '2024' = "PRAC_B"),
"Proselyte" = list('2007' = "q42d", '2014' = "qi2g", '2024' = "PRAC_D")
)
replace_99_9_w_na <- function(data07, data14, data24, instr){
for (var in names(instr)){
print(var)
data07[[var]] <- ifelse(data07[[instr[[var]][['2007']]]] == 9, NA, data07[[instr[[var]][['2007']]]])
data14[[var]] <- ifelse(data14[[instr[[var]][['2014']]]] == 9, NA, data14[[instr[[var]][['2014']]]])
data24[[var]] <- ifelse(data24[[instr[[var]][['2024']]]] == 99, NA, data24[[instr[[var]][['2024']]]])
}
return(list(data07 = data07, data14 = data14, data24 = data24))
}
res <- replace_99_9_w_na(data07, data14, data24, list_to_it)
data07 <- res$data07
data14 <- res$data14
data24 <- res$data24
data07$Belief_in_God <- ifelse(data07$q30 == 9, NA, ifelse(data07$q30 == 3, NA, data07$q30))
data14$Belief_in_God <- ifelse(data14$qg1 == 9, NA, ifelse(data14$qg1 == 3, NA, data14$qg1))
data24$Belief_in_God <- ifelse(data24$GOD == 99, NA, data24$GOD)
data07$Certainty <- ifelse(data07$q31 == 9, NA, data07$q31)
data14$Certainty <- ifelse(data14$qg1b == 9, NA, data14$qg1b)
data24$Certainty <- ifelse(data24$GOD2 == 99, NA, data24$GOD2)
data07$bornagain <- ifelse(data07$q18 == 9, NA, data07$q18)
data24$bornagain <- ifelse(data24$BORNFINAL %in% 98:99, NA, data24$BORNFINAL)
data07$religion_rc <- dplyr::case_when(
data07$q16 == 1 & data07$bornagain == 1 ~ "Evangelical",
data07$q16 == 1 & data07$bornagain == 2 ~ "Mainline",
data07$q16 == 3 ~ "Latter-day Saint",
data07$q16 == 2 ~ "Catholic",
TRUE ~ NA_character_
)
data07$religion_rc2 <- dplyr::case_when(
data07$q16 == 1 & data07$bornagain == 1 ~ "Evangelical",
data07$q16 == 1 & data07$bornagain == 2 ~ "Mainline",
data07$q16 == 3 ~ "Latter-day Saint",
data07$q16 == 2 ~ "Catholic",
TRUE ~ "Other Religion"
)
data07$religion_rc_new1 <- dplyr::case_when(
data07$q16 == 1 & data07$q17 == 1 ~ "Baptist",
data07$q16 == 1 & data07$q17 == 2 ~ "Methodist",
data07$q16 == 1 & data07$q17 == 3 ~ "Non-Denominational",
data07$q16 == 1 & data07$q17 == 4 ~ "Lutheran",
data07$q16 == 1 & data07$q17 == 5 ~ "Presbyterian",
data07$q16 == 1 & data07$q17 == 7 ~ "Episcopalian",
data07$q16 == 1 & data07$q17 %in% c(6,8:105) ~ "Other Protestant",
data07$q16 == 3 ~ "Latter-day Saint",
data07$q16 == 2 ~ "Catholic",
TRUE ~ NA_character_
)
data07$religion_rc_new2 <- dplyr::case_when(
data07$q16 == 1 & data07$q17 == 1 ~ "Baptist",
data07$q16 == 1 & data07$q17 == 2 ~ "Methodist",
data07$q16 == 1 & data07$q17 == 3 ~ "Non-Denominational",
data07$q16 == 1 & data07$q17 == 4 ~ "Lutheran",
data07$q16 == 1 & data07$q17 == 5 ~ "Presbyterian",
data07$q16 == 1 & data07$q17 == 7 ~ "Episcopalian",
data07$q16 == 1 & data07$q17 %in% c(6,8:105) ~ "Other Protestant",
data07$q16 == 3 ~ "Latter-day Saint",
data07$q16 == 2 ~ "Catholic",
TRUE ~ "Other Religion"
)
data24$religion_rc <- dplyr::case_when(
data24$CURREL %in% 1000 & data24$bornagain == 1 ~ "Evangelical",
data24$CURREL %in% 1000 & data24$bornagain == 2 ~ "Mainline",
data24$CURREL == 20000 ~ "Latter-day Saint",
data24$CURREL == 10000 ~ "Catholic",
TRUE ~ NA_character_
)
data24$religion_rc2 <- dplyr::case_when(
data24$CURREL %in% 1000 & data24$bornagain == 1 ~ "Evangelical",
data24$CURREL %in% 1000 & data24$bornagain == 2 ~ "Mainline",
data24$CURREL == 20000 ~ "Latter-day Saint",
data24$CURREL == 10000 ~ "Catholic",
TRUE ~ "Other Religion"
)
data07$religion_rc3 <- dplyr::case_when(
data07$q16 == 1 ~ "Protestant",
data07$q16 == 3 ~ "Latter-day Saint",
data07$q16 == 2 ~ "Catholic",
TRUE ~ "Other Religion"
)
data24$religion_rc3 <- dplyr::case_when(
data24$CURREL %in% 1000 ~ "Protestant",
data24$CURREL == 20000 ~ "Latter-day Saint",
data24$CURREL == 10000 ~ "Catholic",
TRUE ~ "Other Religion"
)
data07$raised <- dplyr::case_when(
data07$q50 == 1 ~ "Protestant",
data07$q50 == 2 ~ "Catholic",
data07$q50 == 3 ~ "Latter-day Saint",
TRUE ~ "Other Religion"
)
data24$raised <- dplyr::case_when(
data24$FRMREL %in% 1000 ~ "Protestant",
data24$FRMREL == 20000 ~ "Latter-day Saint",
data24$FRMREL == 10000 ~ "Catholic",
TRUE ~ "Other Religion"
)
data07$raised_new <- dplyr::case_when(
data07$q50 == 1 & data07$q50b == 1 ~ "Baptist",
data07$q50 == 1 & data07$q50b == 2 ~ "Methodist",
data07$q50 == 1 & data07$q50b == 3 ~ "Non-Denominational",
data07$q50 == 1 & data07$q50b == 4 ~ "Lutheran",
data07$q50 == 1 & data07$q50b == 5 ~ "Presbyterian",
data07$q50 == 1 & data07$q50b == 7 ~ "Episcopalian",
data07$q50 == 1 & data07$q50b %in% c(6,8:105) ~ "Other Protestant",
data07$q50 == 3 ~ "Latter-day Saint",
data07$q50 == 2 ~ "Catholic",
TRUE ~ NA_character_
)
data14$raised_new <- dplyr::case_when(
data14$qj1 == 1 & data14$qj2 == 1 ~ "Baptist",
data14$qj1 == 1 & data14$qj2 == 2 ~ "Methodist",
data14$qj1 == 1 & data14$qj2 == 3 ~ "Lutheran",
data14$qj1 == 1 & data14$qj2 == 4 ~ "Presbyterian",
data14$qj1 == 1 & data14$qj2 == 6 ~ "Episcopalian",
data14$qj1 == 1 & data14$qj2 == 12 ~ "Non-Denominational",
data14$qj1 == 1 & data14$qj2 %in% c(5,7:11,16:71) ~ "Other Protestant",
data14$qj1 == 3 ~ "Latter-day Saint",
data14$qj1 == 2 ~ "Catholic",
TRUE ~ NA_character_
)
data14$raised_new2 <- dplyr::case_when(
data14$qj1 == 1 & data14$qj2 == 1 ~ "Baptist",
data14$qj1 == 1 & data14$qj2 == 2 ~ "Methodist",
data14$qj1 == 1 & data14$qj2 == 3 ~ "Lutheran",
data14$qj1 == 1 & data14$qj2 == 4 ~ "Presbyterian",
data14$qj1 == 1 & data14$qj2 == 6 ~ "Episcopalian",
data14$qj1 == 1 & data14$qj2 == 12 ~ "Non-Denominational",
data14$qj1 == 1 & data14$qj2 %in% c(5,7:11,16:71) ~ "Other Protestant",
data14$qj1 == 3 ~ "Latter-day Saint",
data14$qj1 == 2 ~ "Catholic",
TRUE ~ "Other Religion"
)
data14$religion_rc_new1 <- dplyr::case_when(
data14$qe1 %in% 1 & data14$qe2 == 1 ~ "Baptist",
data14$qe1 %in% 1 & data14$qe2 == 2 ~ "Methodist",
data14$qe1 %in% 1 & data14$qe2 == 3 ~ "Lutheran",
data14$qe1 %in% 1 & data14$qe2 == 4 ~ "Presbyterian",
data14$qe1 %in% 1 & data14$qe2 == 6 ~ "Episcopalian",
data14$qe1 %in% 1 & data14$qe2 == 12 ~ "Non-Denominational",
data14$qe1 %in% 1 & data14$qe2 %in% c(5,7:11,16:71) ~ "Other Protestant",
data14$qe1 == 3 ~ "Latter-day Saint",
data14$qe1 == 2 ~ "Catholic",
TRUE ~ NA_character_
)
data14$religion_rc_new2 <- dplyr::case_when(
data14$qe1 %in% 1 & data14$qe2 == 1 ~ "Baptist",
data14$qe1 %in% 1 & data14$qe2 == 2 ~ "Methodist",
data14$qe1 %in% 1 & data14$qe2 == 3 ~ "Lutheran",
data14$qe1 %in% 1 & data14$qe2 == 4 ~ "Presbyterian",
data14$qe1 %in% 1 & data14$qe2 == 6 ~ "Episcopalian",
data14$qe1 %in% 1 & data14$qe2 == 12 ~ "Non-Denominational",
data14$qe1 %in% 1 & data14$qe2 %in% c(5,7:11,16:71) ~ "Other Protestant",
data14$qe1 == 3 ~ "Latter-day Saint",
data14$qe1 == 2 ~ "Catholic",
TRUE ~ "Other Religion"
)
# data24$raised_new <- dplyr::case_when(
# data24$FRMREL == 1 & data24$FRMREL2 == 1 ~ "Baptist",
# data24$FRMREL == 1 & data24$FRMREL2 == 2 ~ "Methodist",
# data24$FRMREL == 1 & data24$FRMREL2 == 3 ~ "Non-Denominational",
# data24$FRMREL == 1 & data24$FRMREL2 == 4 ~ "Lutheran",
# data24$FRMREL == 1 & data24$FRMREL2 == 5 ~ "Presbyterian",
# data24$FRMREL == 1 & data24$FRMREL2 == 7 ~ "Episcopalian",
# data24$FRMREL == 1 & data24$FRMREL2 %in% c(6,8:18) ~ "Other Protestant",
# data24$FRMREL == 3 ~ "Latter-day Saint",
# data24$FRMREL == 2 ~ "Catholic",
# TRUE ~ NA_character_
# )
# data24$religion_rc_new1 <- dplyr::case_when(
# data24$CURREL %in% 1000 & data24$CURREL2 == 1 ~ "Baptist",
# data24$CURREL %in% 1000 & data24$CURREL2 == 2 ~ "Methodist",
# data24$CURREL %in% 1000 & data24$CURREL2 == 3 ~ "Non-Denominational",
# data24$CURREL %in% 1000 & data24$CURREL2 == 4 ~ "Lutheran",
# data24$CURREL %in% 1000 & data24$CURREL2 == 5 ~ "Presbyterian",
# data24$CURREL %in% 1000 & data24$CURREL2 == 7 ~ "Episcopalian",
# data24$CURREL %in% 1000 & data24$CURREL2 %in% c(6,8:18) ~ "Other Protestant",
# data24$CURREL == 20000 ~ "Latter-day Saint",
# data24$CURREL == 10000 ~ "Catholic",
# TRUE ~ NA_character_
# )
# data24$religion_rc_new2 <- dplyr::case_when(
# data24$CURREL %in% 1000 & data24$CURREL2 == 1 ~ "Baptist",
# data24$CURREL %in% 1000 & data24$CURREL2 == 2 ~ "Methodist",
# data24$CURREL %in% 1000 & data24$CURREL2 == 3 ~ "Non-Denominational",
# data24$CURREL %in% 1000 & data24$CURREL2 == 4 ~ "Lutheran",
# data24$CURREL %in% 1000 & data24$CURREL2 == 5 ~ "Presbyterian",
# data24$CURREL %in% 1000 & data24$CURREL2 == 7 ~ "Episcopalian",
# data24$CURREL %in% 1000 & data24$CURREL2 %in% c(6,8:18) ~ "Other Protestant",
# data24$CURREL == 20000 ~ "Latter-day Saint",
# data24$CURREL == 10000 ~ "Catholic",
# TRUE ~ "Other Religion"
# )
data07$disaffiliation <- ifelse(data07$raised == data07$religion_rc3, 0, 1)
data24$disaffiliation <- ifelse(data24$raised == data24$religion_rc3, 0, 1)
data07$stayed <- ifelse(data07$q50 == data07$q16, 1, 0)
data14$stayed <- ifelse(data14$raised_new2 == data14$religion_rc_new2, 1, 0)
data24$stayed <- ifelse(data24$CURREL == data24$FRMREL, 1, 0)
tbl8 <- data07 |>
count(religion_rc2, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
bind_rows(
data24 |>
count(religion_rc2, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024)
) |>
select(year, religion_rc2, prop) |>
pivot_wider(names_from = religion_rc2, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) / first(.) * 100)) |>
mutate(
metric = '% Change In US Population',
source = "PRLS (2007-2024)") |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl9 <- data07 |>
group_by(religion_rc) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Scriptures == 1) |>
bind_rows(
data24 |>
group_by(religion_rc) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Scriptures == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Weekly or more Scripture Reading',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl10 <- data07 |>
mutate(Scriptures = ifelse(Scriptures %in% 1:2, 1, 0)) |>
group_by(religion_rc) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Scriptures == 1) |>
bind_rows(
data24 |>
mutate(Scriptures = ifelse(Scriptures %in% 1:2, 1, 0)) |>
group_by(religion_rc) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Scriptures == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Monthly or more Scripture Reading',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl11 <- data07 |>
group_by(religion_rc) |>
count(Belief_in_God, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Belief_in_God == 1) |>
bind_rows(
data24 |>
group_by(religion_rc) |>
count(Belief_in_God, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Belief_in_God == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Belief in God',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl12 <- data07 |>
group_by(religion_rc) |>
count(Certainty, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Certainty == 1) |>
bind_rows(
data24 |>
group_by(religion_rc) |>
count(Certainty, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Certainty == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Belief in God With Certainty',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl13 <- data07 |>
group_by(religion_rc) |>
count(Prayer_Frequency, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Prayer_Frequency == 1) |>
bind_rows(
data24 |>
group_by(religion_rc) |>
count(Prayer_Frequency, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Prayer_Frequency == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Praying Several Time A Day',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl14 <- data07 |>
group_by(religion_rc) |>
count(Church_Education, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Church_Education == 1) |>
bind_rows(
data24 |>
group_by(religion_rc) |>
count(Church_Education, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Church_Education == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Participate in Weekly Religious Education Programs',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl15 <- data07 |>
group_by(religion_rc) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Proselyte == 1) |>
bind_rows(
data24 |>
group_by(religion_rc) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Proselyte == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Share your religious views weekly',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl16 <- data07 |>
mutate(Proselyte = ifelse(Proselyte %in% 1:2, 1, 0)) |>
group_by(religion_rc) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Proselyte == 1) |>
bind_rows(
data24 |>
mutate(Proselyte = ifelse(Proselyte %in% 1:2, 1, 0)) |>
group_by(religion_rc) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Proselyte == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Share your religious views monthly',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl17 <- data07 |>
group_by(raised) |>
count(stayed, wt=weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(stayed == 1) |>
bind_rows(
data24 |>
group_by(raised) |>
count(stayed, wt= WEIGHT) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(stayed == 1)
) |>
select(year, raised, prop) |>
pivot_wider(names_from = raised, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Stayed With Childhood Religion',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Protestant, `Latter-day Saint`)
# GSS
# Load the dataset
data_gss <- haven::read_sav("./data/GSS_spss/gss7224_r3.sav")
# They have no Mormon data for 2024, so I'm going to filter out 2024
table(data_gss$other == 64, data_gss$year)
data_gss <- data_gss |> filter(year < 2024)
data_gss <- data_gss |>
mutate(
relig_rc = case_when(
# Catholic
relig == 2 ~ "Catholic",
# Jewish
relig == 3 ~ "Jewish",
# No religion
relig == 4 ~ "No Religion",
# LDS (based on var2 write-ins)
other %in% c(64) ~ "Latter-day Saint",
# Black Protestant (based on var2 and var3)
other %in% c(15,37,186,21,20,13,12) | denom %in% c(20,21,12,13) ~ "Black Protestant",
# Evangelical Protestant
(
relig == 1 & (
other %in% c(
3,5,6,12,17,18,45,46,47,52,53,66,67,68,69,103,112,120,134,181
) |
denom %in% c(
14,32,33,35,10,70
)
)
) ~ "Evangelical",
# Mainline Protestant
(
relig == 1 & (
other %in% c(
8,19,24,25,28,31,32,34,40,41,42,43,44,48,50,71,72,73,81,82,83
) |
denom %in% c(
11,22,23,28,30,31,34,38,40,41,42,43,48,50
)
)
) ~ "Mainline",
# Other
TRUE ~ "Other",
is.na(relig) ~ NA_character_
),
relig16_rc = case_when(
# Catholic
relig16 == 2 ~ "Catholic",
# Jewish
relig16 == 3 ~ "Jewish",
# No religion
relig16 == 4 ~ "No Religion",
# LDS (based on var2 write-ins)
oth16 %in% c(64) ~ "Latter-day Saint",
# Black Protestant (based on var2 and var3)
oth16 %in% c(15,37,186,21,20,13,12) | denom16 %in% c(20,21,12,13) ~ "Black Protestant",
# Evangelical Protestant
(
relig16 == 1 & (
oth16 %in% c(
3,5,6,12,17,18,45,46,47,52,53,66,67,68,69,103,112,120,134,181
) |
denom16 %in% c(
14,32,33,35,10,70
)
)
) ~ "Evangelical",
# Mainline Protestant
(
relig16 == 1 & (
oth16 %in% c(
8,19,24,25,28,31,32,34,40,41,42,43,44,48,50,71,72,73,81,82,83
) |
denom16 %in% c(
11,22,23,28,30,31,34,38,40,41,42,43,48,50
)
)
) ~ "Mainline",
# Other
TRUE ~ "Other",
is.na(relig16) ~ NA_character_
)
)
data_gss$religion_rc_new1 <- case_when(
data_gss$other == 64 ~ "Latter-day Saint",
data_gss$relig == 1 & data_gss$denom == 1 ~ "Baptist",
data_gss$relig == 1 & data_gss$denom == 2 ~ "Methodist",
data_gss$relig == 1 & data_gss$denom == 7 ~ "Non-Denominational",
data_gss$relig == 1 & data_gss$denom == 3 ~ "Lutheran",
data_gss$relig == 1 & data_gss$denom == 4 ~ "Presbyterian",
data_gss$relig == 1 & data_gss$denom == 5 ~ "Episcopalian",
data_gss$relig == 1 & data_gss$denom == 6 ~ "Other Protestant",
data_gss$relig == 2 ~ "Catholic",
TRUE ~ NA_character_
)
data_gss$religion_rc_new2 <- case_when(
data_gss$other == 64 ~ "Latter-day Saint",
data_gss$relig == 1 & data_gss$denom == 1 ~ "Baptist",
data_gss$relig == 1 & data_gss$denom == 2 ~ "Methodist",
data_gss$relig == 1 & data_gss$denom == 7 ~ "Non-Denominational",
data_gss$relig == 1 & data_gss$denom == 3 ~ "Lutheran",
data_gss$relig == 1 & data_gss$denom == 4 ~ "Presbyterian",
data_gss$relig == 1 & data_gss$denom == 5 ~ "Episcopalian",
data_gss$relig == 1 & data_gss$denom == 6 ~ "Other Protestant",
data_gss$relig == 2 ~ "Catholic",
TRUE ~ "Other Religion"
)
data_gss$raised_new_1 <- case_when(
data_gss$oth16 == 64 ~ "Latter-day Saint",
data_gss$relig16 == 1 & data_gss$denom16 == 1 ~ "Baptist",
data_gss$relig16 == 1 & data_gss$denom16 == 2 ~ "Methodist",
data_gss$relig16 == 1 & data_gss$denom16 == 7 ~ "Non-Denominational",
data_gss$relig16 == 1 & data_gss$denom16 == 3 ~ "Lutheran",
data_gss$relig16 == 1 & data_gss$denom16 == 4 ~ "Presbyterian",
data_gss$relig16 == 1 & data_gss$denom16 == 5 ~ "Episcopalian",
data_gss$relig16 == 1 & data_gss$denom16 == 6 ~ "Other Protestant",
data_gss$relig16 == 2 ~ "Catholic",
TRUE ~ "Other Religion"
)
data_gss$decade <- case_when(
data_gss$year %in% 1970:1989 ~ 1980,
data_gss$year %in% 1990:1999 ~ 1990,
data_gss$year %in% 2000:2009 ~ 2000,
data_gss$year %in% 2010:2029 ~ 2020
)
data_gss$generation <- factor(case_when(
data_gss$cohort %in% 1890:1945 ~ "Greatest/Silent",
data_gss$cohort %in% 1946:1964 ~ "Boomer",
data_gss$cohort %in% 1965:1980 ~ "Gen X",
data_gss$cohort %in% 1981:2020 ~ "Mil/GenZ"
), levels = c("Greatest/Silent", "Boomer", "Gen X", "Mil/GenZ"))
data_gss$stayed_mormon <- dplyr::case_when(
data_gss$oth16 %in% c(64) & data_gss$other %in% c(64) ~ 1,
data_gss$oth16 %in% c(64) & !(data_gss$other %in% c(64)) ~ 0,
TRUE ~ NA_real_
)
data_gss$became_non_relig <- dplyr::case_when(
data_gss$relig16_rc != "No Religion" & data_gss$relig_rc == "No Religion" ~ 1,
data_gss$relig16_rc != "No Religion" & data_gss$relig_rc != "No Religion" ~ 0,
data_gss$relig16_rc == "No Religion" & data_gss$relig_rc == "No Religion" ~ 1,
data_gss$relig16_rc == "No Religion" & data_gss$relig_rc != "No Religion" ~ 0,
TRUE ~ NA_real_
)
data_gss$changed_religion <- dplyr::case_when(
data_gss$relig16_rc != data_gss$relig_rc ~ 1,
TRUE ~ 0
)
data_gss$changed_religion_new1 <- dplyr::case_when(
data_gss$raised_new_1 != data_gss$religion_rc_new2 ~ 1,
TRUE ~ 0
)
tbl18 <- data_gss |>
group_by(decade) |>
filter(decade %in% c(1990, 2020)) |>
count(relig_rc, wt = wtssps) |>
mutate(prop = n / sum(n)) |>
select(decade, relig_rc, prop) |>
ungroup() |>
pivot_wider(names_from = relig_rc, values_from = prop) %>%
dplyr::summarise(dplyr::across(dplyr::where(is.numeric), ~ (dplyr::last(.) - dplyr::first(.)) / dplyr::first(.) * 100)) |>
mutate(
metric = '% Change In US Population',
source = "GSS (1990s-2020s)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl19 <- data_gss |>
group_by(decade, relig_rc) |>
mutate(attend = case_when(
attend %in% 7:8 ~ "Weekly or More",
attend %in% 0:6 ~ "Less Than Weekly",
TRUE ~ NA_character_
)) |>
filter(decade %in% c(1980, 2020)) |>
count(attend, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(attend == "Weekly or More") |>
select(decade, relig_rc, prop) |>
ungroup() |>
pivot_wider(names_from = relig_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = '% Weekly Attenders',
source = "GSS (1980s-2020s)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl20 <- data_gss |>
group_by(decade, relig_rc) |>
mutate(attend = case_when(
attend %in% 4:8 ~ "Monthly or More",
attend %in% 0:3 ~ "Less Than Monthly",
TRUE ~ NA_character_
)) |>
filter(decade %in% c(1980, 2020)) |>
count(attend, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(attend == "Monthly or More") |>
select(decade, attend, relig_rc, prop) |>
ungroup() |>
pivot_wider(names_from = relig_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = '% Monthly Attenders',
source = "GSS (1980s-2020s)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl21 <- data_gss |>
group_by(decade, relig16_rc) |>
filter(decade %in% c(1980, 2020)) |>
count(changed_religion, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(changed_religion == 0) |>
select(decade, relig16_rc, prop) |>
ungroup() |>
pivot_wider(names_from = relig16_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = '% Stayed in Same Religion',
source = "GSS (1980s-2020s)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl <- bind_rows(tbl1, tbl2, tbl3, tbl4, tbl5, tbl6, tbl7, tbl8, tbl9, tbl10, tbl11, tbl12, tbl13, tbl14, tbl15, tbl16, tbl18, tbl19, tbl20, tbl21)
# Here is table 1
clipr::write_clip(tbl)
table(data_gss$relig_rc, data_gss$year)
# Here is chart #1 LDS Lead as snapshot
clipr::write_clip(
data |>
filter(year == 2024) |>
group_by(religion_rc) |>
count(relig_imp_rc, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(relig_imp_rc == "Very Important") |>
select(religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
mutate(label = "Religion is very important in my life") |>
select(label,Catholic, Evangelical, `Latter-day Saint`, Mainline) |>
bind_rows(
data |>
filter(year == 2024) |>
group_by(religion_rc) |>
count(relig_church_rc, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(relig_church_rc == "Weekly or More") |>
select(religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
mutate(label = "Attend church weekly or more") |>
select(label,Catholic, Evangelical, `Latter-day Saint`, Mainline)
) |>
bind_rows(
data |>
filter(year == 2024) |>
group_by(religion_rc) |>
count(prayer_rc, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(prayer_rc == "Several Times a Day") |>
select(religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
mutate(label = "Pray several times a day") |>
select(label,Catholic, Evangelical, `Latter-day Saint`, Mainline)
) |>
bind_rows(
data24 |>
group_by(religion_rc) |>
count(Certainty, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Certainty == 1) |>
select(religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
mutate(label = "Believe in God with Certainty") |>
select(label,Catholic, Evangelical, `Latter-day Saint`, Mainline)
)
)
# Chart #3 LDS Snapshot under 40
clipr::write_clip(
data |>
filter(year == 2024) |>
filter(age %in% 18:45) |>
group_by(religion_rc) |>
count(relig_imp_rc, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(relig_imp_rc == "Very Important") |>
select(religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
mutate(label = "Religion is very important in my life") |>
select(label,Catholic, Evangelical, `Latter-day Saint`, Mainline) |>
bind_rows(
data |>
filter(year == 2024) |>
filter(age %in% 18:45) |>
group_by(religion_rc) |>
count(relig_church_rc, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(relig_church_rc == "Weekly or More") |>
select(religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
mutate(label = "Attend church weekly or more") |>
select(label,Catholic, Evangelical, `Latter-day Saint`, Mainline)
) |>
bind_rows(
data |>
filter(year == 2024) |>
filter(age %in% 18:45) |>
group_by(religion_rc) |>
count(prayer_rc, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(prayer_rc == "Several Times a Day") |>
select(religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
mutate(label = "Pray several times a day") |>
select(label,Catholic, Evangelical, `Latter-day Saint`, Mainline)
) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
group_by(religion_rc) |>
count(Certainty, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Certainty == 1) |>
select(religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
mutate(label = "Believe in God with Certainty") |>
select(label,Catholic, Evangelical, `Latter-day Saint`, Mainline)
)
)
# Now I need to make Table 2
tbl1 <- data |>
filter(year > 2007) |>
filter(age %in% 18:45) |>
group_by(year, religion_rc) |>
count(relig_church_rc, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_church_rc == "Weekly or More") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Weekly Church Attendance',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl2 <- data |>
filter(year > 2007) |>
filter(age %in% 18:45) |>
group_by(year, religion_rc) |>
count(relig_church_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_church_rc2 == "Monthly or More") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Monthly Church Attendance',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl3 <- data |>
filter(year > 2007) |>
filter(age %in% 18:45) |>
group_by(year, religion_rc) |>
count(prayer_rc, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(prayer_rc == "Several Times a Day") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Several Times A Day Prayer',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl4 <- data |>
filter(year > 2007) |>
filter(age %in% 18:45) |>
group_by(year, religion_rc) |>
count(prayer_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(prayer_rc2 == "Daily or More") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Daily or More Prayer',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl5 <- data |>
filter(year > 2007) |>
filter(age %in% 18:45) |>
group_by(year, religion_rc) |>
count(relig_imp_rc, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_imp_rc == "Very Important") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Religion is Very Important',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl6 <- data |>
filter(year > 2007) |>
filter(age %in% 18:45) |>
group_by(year, religion_rc) |>
count(relig_imp_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_imp_rc2 == "Very/somewhat Important") |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Religion is Very/Somewhat Important',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl7 <- data |>
filter(year > 2008) |>
filter(age %in% 18:45) |>
group_by(year) |>
count(religion_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
select(year, religion_rc2, prop) |>
pivot_wider(names_from = religion_rc2, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) / first(.) * 100)) |>
mutate(
metric = '% Change In US Population',
source = "CES (2008-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl8 <- data07 |>
filter(age %in% 18:45) |>
count(religion_rc2, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
count(religion_rc2, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024)
) |>
select(year, religion_rc2, prop) |>
pivot_wider(names_from = religion_rc2, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) / first(.) * 100)) |>
mutate(
metric = '% Change In US Population',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl9 <- data07 |>
filter(age %in% 18:45) |>
group_by(religion_rc) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Scriptures == 1) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
group_by(religion_rc) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Scriptures == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Weekly or more Scripture Reading',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl10 <- data07 |>
filter(age %in% 18:45) |>
mutate(Scriptures = ifelse(Scriptures %in% 1:2, 1, 0)) |>
group_by(religion_rc) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Scriptures == 1) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
mutate(Scriptures = ifelse(Scriptures %in% 1:2, 1, 0)) |>
group_by(religion_rc) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Scriptures == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Monthly or more Scripture Reading',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl11 <- data07 |>
filter(age %in% 18:45) |>
group_by(religion_rc) |>
count(Belief_in_God, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Belief_in_God == 1) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
group_by(religion_rc) |>
count(Belief_in_God, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Belief_in_God == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Belief in God',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl12 <- data07 |>
filter(age %in% 18:45) |>
group_by(religion_rc) |>
count(Certainty, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Certainty == 1) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
group_by(religion_rc) |>
count(Certainty, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Certainty == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Belief in God With Certainty',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl13 <- data07 |>
filter(age %in% 18:45) |>
group_by(religion_rc) |>
count(Prayer_Frequency, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Prayer_Frequency == 1) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
group_by(religion_rc) |>
count(Prayer_Frequency, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Prayer_Frequency == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Praying Several Time A Day',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl14 <- data07 |>
filter(age %in% 18:45) |>
group_by(religion_rc) |>
count(Church_Education, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Church_Education == 1) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
group_by(religion_rc) |>
count(Church_Education, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Church_Education == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Participate in Weekly Religious Education Programs',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl15 <- data07 |>
filter(age %in% 18:45) |>
group_by(religion_rc) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Proselyte == 1) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
group_by(religion_rc) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Proselyte == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Share your religious views weekly',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl16 <- data07 |>
filter(age %in% 18:45) |>
mutate(Proselyte = ifelse(Proselyte %in% 1:2, 1, 0)) |>
group_by(religion_rc) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Proselyte == 1) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
mutate(Proselyte = ifelse(Proselyte %in% 1:2, 1, 0)) |>
group_by(religion_rc) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(Proselyte == 1)
) |>
select(year, religion_rc, prop) |>
pivot_wider(names_from = religion_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Share your religious views monthly',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl17 <- data07 |>
filter(age %in% 18:45) |>
group_by(raised) |>
count(stayed, wt=weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(stayed == 1) |>
bind_rows(
data24 |>
filter(BIRTHDECADE %in% 5:7) |>
group_by(raised) |>
count(stayed, wt= WEIGHT) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2024) |>
filter(stayed == 1)
) |>
select(year, raised, prop) |>
pivot_wider(names_from = raised, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Stayed With Childhood Religion',
source = "PRLS (2007-2024)"
) |>
select(metric, source, Catholic, Protestant, `Latter-day Saint`)
tbl18 <- data_gss |>
filter(age %in% 18:45) |>
group_by(decade) |>
filter(decade %in% c(1990, 2020)) |>
count(relig_rc, wt = wtssps) |>
mutate(prop = n / sum(n)) |>
select(decade, relig_rc, prop) |>
ungroup() |>
pivot_wider(names_from = relig_rc, values_from = prop) %>%
dplyr::summarise(dplyr::across(dplyr::where(is.numeric), ~ (dplyr::last(.) - dplyr::first(.)) / dplyr::first(.) * 100)) |>
mutate(
metric = '% Change In US Population',
source = "GSS (1990s-2020s)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl19 <- data_gss |>
filter(age %in% 18:45) |>
group_by(decade, relig_rc) |>
mutate(attend = case_when(
attend %in% 7:8 ~ "Weekly or More",
attend %in% 0:6 ~ "Less Than Weekly",
TRUE ~ NA_character_
)) |>
filter(decade %in% c(1980, 2020)) |>
count(attend, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(attend == "Weekly or More") |>
select(decade, relig_rc, prop) |>
ungroup() |>
pivot_wider(names_from = relig_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = '% Weekly Attenders',
source = "GSS (1980s-2020s)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl20 <- data_gss |>
filter(age %in% 18:45) |>
group_by(decade, relig_rc) |>
mutate(attend = case_when(
attend %in% 4:8 ~ "Monthly or More",
attend %in% 0:3 ~ "Less Than Monthly",
TRUE ~ NA_character_
)) |>
filter(decade %in% c(1980, 2020)) |>
count(attend, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(attend == "Monthly or More") |>
select(decade, attend, relig_rc, prop) |>
ungroup() |>
pivot_wider(names_from = relig_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = '% Monthly Attenders',
source = "GSS (1980s-2020s)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tbl21 <- data_gss |>
filter(age %in% 18:45) |>
group_by(decade, relig16_rc) |>
filter(decade %in% c(1980, 2020)) |>
count(changed_religion, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(changed_religion == 0) |>
select(decade, relig16_rc, prop) |>
ungroup() |>
pivot_wider(names_from = relig16_rc, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = '% Stayed in Same Religion',
source = "GSS (1980s-2020s)"
) |>
select(metric, source, Catholic, Evangelical, `Latter-day Saint`, Mainline)
tblpt2 <- bind_rows(tbl1, tbl2, tbl3, tbl4, tbl5, tbl6, tbl7, tbl8, tbl9, tbl10, tbl11, tbl12, tbl13, tbl14, tbl15, tbl16, tbl18, tbl19, tbl20, tbl21)
clipr::write_clip(tblpt2)
# By Denomination Table #3
tbl1 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc_new1) |>
count(relig_church_rc, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_church_rc == "Weekly or More") |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Weekly Church Attendance',
source = "CES (2008-2024)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl2 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc_new1) |>
count(relig_church_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_church_rc2 == "Monthly or More") |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Monthly Church Attendance',
source = "CES (2008-2024)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl3 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc_new1) |>
count(prayer_rc, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(prayer_rc == "Several Times a Day") |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Several Times A Day Prayer',
source = "CES (2008-2024)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl4 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc_new1) |>
count(prayer_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(prayer_rc2 == "Daily or More") |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Daily or More Prayer',
source = "CES (2008-2024)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl5 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc_new1) |>
count(relig_imp_rc, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_imp_rc == "Very Important") |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Religion is Very Important',
source = "CES (2008-2024)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl6 <- data |>
filter(year > 2007) |>
group_by(year, religion_rc_new1) |>
count(relig_imp_rc2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
filter(relig_imp_rc2 == "Very/somewhat Important") |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Religion is Very/Somewhat Important',
source = "CES (2008-2024)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl7 <- data |>
filter(year > 2008) |>
group_by(year) |>
count(religion_rc_new2, wt = weight) |>
drop_na() |>
mutate(
prop = n / sum(n),
ci_low = binom.confint(n, sum(n), method = "wilson")$lower,
ci_high = binom.confint(n, sum(n), method = "wilson")$upper
) |>
select(year, religion_rc_new2, prop) |>
pivot_wider(names_from = religion_rc_new2, values_from = prop) |>
ungroup() |>
filter(year %in% c(max(year), min(year))) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) / first(.) * 100)) |>
mutate(
metric = '% Change In US Population',
source = "CES (2008-2024)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
# Some Pew Numbers calculated manually since 2024 Restricted Use File not available to the public yet.
tbl9 <- data07 |>
group_by(religion_rc_new1) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Scriptures == 1) |>
bind_rows(
data14 |>
group_by(religion_rc_new1) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2014) |>
filter(Scriptures == 1)
) |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Weekly or more Scripture Reading',
source = "PRLS (2007-2014)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl10 <- data07 |>
mutate(Scriptures = ifelse(Scriptures %in% 1:2, 1, 0)) |>
group_by(religion_rc_new1) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Scriptures == 1) |>
bind_rows(
data14 |>
mutate(Scriptures = ifelse(Scriptures %in% 1:2, 1, 0)) |>
group_by(religion_rc_new1) |>
count(Scriptures, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2014) |>
filter(Scriptures == 1)
) |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Monthly or more Scripture Reading',
source = "PRLS (2007-2014)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl11 <- data07 |>
group_by(religion_rc_new1) |>
count(Belief_in_God, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Belief_in_God == 1) |>
bind_rows(
data14 |>
group_by(religion_rc_new1) |>
count(Belief_in_God, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2014) |>
filter(Belief_in_God == 1)
) |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Belief in God',
source = "PRLS (2007-2014)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl12 <- data07 |>
group_by(religion_rc_new1) |>
count(Certainty, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Certainty == 1) |>
bind_rows(
data14 |>
group_by(religion_rc_new1) |>
count(Certainty, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2014) |>
filter(Certainty == 1)
) |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Belief in God With Certainty',
source = "PRLS (2007-2014)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl13 <- data07 |>
group_by(religion_rc_new1) |>
count(Prayer_Frequency, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Prayer_Frequency == 1) |>
bind_rows(
data14 |>
group_by(religion_rc_new1) |>
count(Prayer_Frequency, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2014) |>
filter(Prayer_Frequency == 1)
) |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Praying Several Time A Day',
source = "PRLS (2007-2014)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl14 <- data07 |>
group_by(religion_rc_new1) |>
count(Church_Education, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Church_Education == 1) |>
bind_rows(
data14 |>
group_by(religion_rc_new1) |>
count(Church_Education, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2014) |>
filter(Church_Education == 1)
) |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Participate in Weekly Religious Education Programs',
source = "PRLS (2007-2014)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl15 <- data07 |>
group_by(religion_rc_new1) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Proselyte == 1) |>
bind_rows(
data14 |>
group_by(religion_rc_new1) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2014) |>
filter(Proselyte == 1)
) |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Share your religious views weekly',
source = "PRLS (2007-2014)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl16 <- data07 |>
mutate(Proselyte = ifelse(Proselyte %in% 1:2, 1, 0)) |>
group_by(religion_rc_new1) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(Proselyte == 1) |>
bind_rows(
data14 |>
mutate(Proselyte = ifelse(Proselyte %in% 1:2, 1, 0)) |>
group_by(religion_rc_new1) |>
count(Proselyte, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2014) |>
filter(Proselyte == 1)
) |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = 'Share your religious views monthly',
source = "PRLS (2007-2014)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl18 <- data_gss |>
group_by(decade) |>
filter(decade %in% c(1990, 2020)) |>
count(religion_rc_new2, wt = wtssps) |>
mutate(prop = n / sum(n)) |>
select(decade, religion_rc_new2, prop) |>
ungroup() |>
pivot_wider(names_from = religion_rc_new2, values_from = prop) %>%
dplyr::summarise(dplyr::across(dplyr::where(is.numeric), ~ (dplyr::last(.) - dplyr::first(.)) / dplyr::first(.) * 100)) |>
mutate(
metric = '% Change In US Population',
source = "GSS (1990s-2020s)") |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl19 <- data_gss |>
group_by(decade, religion_rc_new1) |>
mutate(attend = case_when(
attend %in% 7:8 ~ "Weekly or More",
attend %in% 0:6 ~ "Less Than Weekly",
TRUE ~ NA_character_
)) |>
filter(decade %in% c(1980, 2020)) |>
count(attend, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(attend == "Weekly or More") |>
select(decade, religion_rc_new1, prop) |>
ungroup() |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = '% Weekly Attenders',
source = "GSS (1980s-2020s)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl20 <- data_gss |>
group_by(decade, religion_rc_new1) |>
mutate(attend = case_when(
attend %in% 4:8 ~ "Monthly or More",
attend %in% 0:3 ~ "Less Than Monthly",
TRUE ~ NA_character_
)) |>
filter(decade %in% c(1980, 2020)) |>
count(attend, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(attend == "Monthly or More") |>
select(decade, attend, religion_rc_new1, prop) |>
ungroup() |>
pivot_wider(names_from = religion_rc_new1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = '% Monthly Attenders',
source = "GSS (1980s-2020s)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tbl21 <- data_gss |>
group_by(decade, raised_new_1) |>
filter(decade %in% c(1980, 2020)) |>
count(changed_religion_new1, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(changed_religion_new1 == 0) |>
select(decade, raised_new_1, prop) |>
ungroup() |>
pivot_wider(names_from = raised_new_1, values_from = prop) %>%
summarise(across(where(is.numeric), ~ (last(.) - first(.)) * 100)) |>
mutate(
metric = '% Stayed in Same Religion',
source = "GSS (1980s-2020s)"
) |>
select(metric, source, Baptist, Catholic, `Latter-day Saint`, Lutheran, Methodist, `Non-Denominational`, Presbyterian)
tblpt3 <- bind_rows(tbl1, tbl2, tbl3, tbl4, tbl5, tbl6, tbl7, tbl9, tbl10, tbl11, tbl12, tbl13, tbl14, tbl15, tbl16, tbl18, tbl19, tbl20, tbl21)
clipr::write_clip(tblpt3)
clipr::write_clip(
data07 |>
count(religion_rc_new2, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
select(year, religion_rc_new2, prop) |>
pivot_wider(names_from = religion_rc_new2, values_from = prop)
)
clipr::write_clip(
data07 |>
group_by(raised_new) |>
count(stayed, wt=weight) |>
drop_na() |>
mutate(prop = n / sum(n), year = 2007) |>
filter(stayed == 1) |>
select(year, raised_new, prop) |>
pivot_wider(names_from = raised_new, values_from = prop)
)
write_clip(
data |>
filter(year == 2024) |>
group_by(year, religion_rc_new1) |>
count(relig_church_rc, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(relig_church_rc == "Weekly or More") |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop)
)
write_clip(
data |>
filter(year == 2024) |>
group_by(year, religion_rc_new1) |>
count(relig_imp_rc, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(relig_imp_rc == "Very Important") |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop)
)
write_clip(
data |>
filter(year == 2024) |>
group_by(year, religion_rc_new1) |>
count(prayer_rc, wt = weight) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(prayer_rc == "Several Times a Day") |>
select(year, religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop)
)
write_clip(
data_gss |>
filter(year %in% 2010:2022) |>
group_by(religion_rc_new1) |>
count(god, wt = wtssps) |>
drop_na() |>
mutate(prop = n / sum(n)) |>
filter(god == 6) |>
select(religion_rc_new1, prop) |>
pivot_wider(names_from = religion_rc_new1, values_from = prop)
)
#gist: https://gist.github.com/acbass49/77c6d6c81779818555c6a9598ff2820e
# gist -u GIST_ID myfile.R
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment