Skip to content

Instantly share code, notes, and snippets.

@ryanburge
Created June 25, 2019 20:28
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/c847f0cd3a1c3fcc1fb741d8bc1a8d1a to your computer and use it in GitHub Desktop.
Save ryanburge/c847f0cd3a1c3fcc1fb741d8bc1a8d1a to your computer and use it in GitHub Desktop.
Reltrad Attempt.
graph <- gss %>%
filter(year == 2018) %>%
mutate(reltrad = replace_na(reltrad, 0)) %>%
mutate(trad = frcode(other == 59 | other == 60 | other == 61 | other == 62 | other == 64 ~ "Mormon",
race == 2 & relig == 1 ~ "Black\nProt.",
reborn == 2 & relig == 1 ~ "Non-Evan.\nProtestant",
reborn == 1 & race == 3 ~ "Non-White\nEvangelical",
reborn == 1 & race == 1 ~ "White\nEvangelical",
reltrad == 4 ~ "Catholic",
reltrad == 5 ~ "Jewish",
relig == 6 ~ "Buddhist",
relig == 7 ~ "Hindu",
relig == 10 ~ "Orthodox",
reltrad == 7 ~ "None",
TRUE ~ "All\nOthers")) %>%
ct(trad, wt = wtsall)
graph %>%
ggplot(., aes(x = reorder(trad, -pct), y = pct, fill = pct)) +
geom_col(color = "black") +
theme_gg("Abel") +
scale_fill_gradient(low = "#FF6B6B", high = "#556270") +
geom_text(aes(y = pct + .0085, label = paste0(pct*100, '%')), position = position_dodge(width = .9), size = 4, family = "font") +
scale_y_continuous(labels = percent) +
labs(x = "", y = "", title = "RELTRAD as Identification Scheme", caption = "@pauldjupe\n@ryanburge\nData: GSS 2018") +
ggsave("E://reltrad_scheme.png", type = "cairo-png", width = 9)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment