Skip to content

Instantly share code, notes, and snippets.

@ryanburge
Created July 19, 2022 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburge/ce68230f56603bd1d007cfd0209fd6f0 to your computer and use it in GitHub Desktop.
Save ryanburge/ce68230f56603bd1d007cfd0209fd6f0 to your computer and use it in GitHub Desktop.
library(googlesheets4)
library(lubridate)
clean <- read_sheet("https://docs.google.com/spreadsheets/d/1hy0Wa-BKt6XTAuqj6uxQyyCwJ6mN6_Xtv2NBz9_R8RA/edit?usp=sharing")
att <- clean %>%
filter(type == "att") %>%
mutate(change = (value - lag(value))/lag(value))
att <- att %>%
mutate(pct = change * 100) %>%
mutate(pct = round(pct, 1)) %>%
mutate(pct = paste0(pct, "%")) %>%
mutate(lab = value/1000) %>%
mutate(lab = round(lab, 0)) %>%
mutate(lab = paste0(lab, "K"))
att %>%
ggplot(., aes(x = factor(year), y = value, fill = value)) +
geom_col(color = "black") +
theme_rb() +
scale_fill_gradient(high = "#7303c0", low = "#fdeff9") +
geom_text(aes(y = value + 20000, label = lab), position = position_dodge(width = .9), size = 4, family = "font") +
geom_text(aes(y = 30000, label = ifelse(pct != "NA%", pct, '')), position = position_dodge(width = .9), size = 4, family = "font") +
scale_y_continuous(labels = label_number(suffix = "K", scale = 1e-3)) +
labs(x = "Year", y = "", title = "Sunday Church Attendance for the Episcopalians", caption = "@ryanburge\nData: https://www.generalconvention.org/parochialreportresults")
ggsave("E://epis_attend.png", type = "cairo-png", bg = "white", width = 7)
off <- clean %>%
filter(type == "offering") %>%
mutate(lab = value/1000000000) %>%
mutate(lab = round(lab, 2)) %>%
mutate(lab = paste0(lab, "B"))
off %>%
ggplot(., aes(x = factor(year), y = value, fill = value)) +
geom_col(color = "black") +
scale_y_continuous(labels = label_number(suffix = "B", scale = 1e-9)) +
geom_text(aes(y = value + 60000000, label = lab), position = position_dodge(width = .9), size = 6, family = "font") +
theme_rb() +
scale_fill_gradient(low = "#B06AB3", high = "#4568DC") +
labs(x = "", y = "", title = "Plate and Pledge Annual Totals for TEC", caption = "@ryanburge\nData: https://www.generalconvention.org/parochialreportresults")
ggsave("E://tec_offering.png", type = 'cairo-png', bg = "white")
att <- clean %>%
filter(type == "att") %>%
select(year, att = value)
off <- clean %>%
filter(type == "offering") %>%
select(year, off = value)
graph <- left_join(att, off) %>%
na.omit() %>%
mutate(give = off/att) %>%
mutate(give = round(give, 0)) %>%
mutate(lab = paste0("$", give))
graph %>%
ggplot(., aes(x = factor(year), y = give, fill = give)) +
geom_col(color = "black") +
geom_text(aes(y = give + 100, label = lab), position = position_dodge(width = .9), size = 6, family = "font") +
theme_rb() +
scale_y_continuous(labels=scales::dollar_format()) +
scale_fill_gradient(low = "#493240", high = "#FF0099") +
labs(x = "", y = "", title = "Annual Offering per Weekly Attender", caption = "@ryanburge\nData: https://www.generalconvention.org/parochialreportresults")
ggsave("E://tec_offering_by_att.png", type = 'cairo-png', bg = 'white')
test <- clean %>%
filter(type == "baptisms" | type == "burial services" | type == "confirmations" | type == "marriages") %>%
filter(year >= 2013) %>%
mutate(year = as.factor(year))
test <- test %>%
mutate(type = frcode(type == "baptisms" ~ "Baptisms",
type == "burial services" ~ "Burials",
type == "confirmations" ~ "Confirmations",
type == "marriages" ~ "Marriages"))
test %>%
ggplot(., aes(x= year, y = value, color = type, group = type)) +
theme_rb() +
scale_color_gdocs() +
scale_y_continuous(limits = c(0, 35000)) +
geom_textline(aes(x = year, y = value, label = type, color = type), size = 6, vjust = -0.25, hjust = -.01, linewidth = 1, linetype = 2, family = 'font') +
geom_point(stroke = 1, shape = 21, fill = 'white') +
labs(x = "", y = "", title = "Baptisms, Burials, Confirmations, and Marriages in TEC (2013-2020)", caption = "@ryanburge\nData: https://www.generalconvention.org/parochialreportresults")
ggsave("E://tec_four_lines.png", type = 'cairo-png', bg = "white", height = 5, width = 8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment