Skip to content

Instantly share code, notes, and snippets.

View ryanburge's full-sized avatar

Ryan Burge ryanburge

View GitHub Profile
@ryanburge
ryanburge / pls_5053_10192022.R
Created October 19, 2022 20:23
PLS 5053 - 10/19/2022
# install.packages("remotes")
# library(remotes)
# remotes::install_github("ryanburge/socsci")
# library(socsci)
cces20 <- read_csv("https://www.dropbox.com/s/wuixmc67ae786wp/small_ces2020.csv?dl=1")
Codebook is here: https://www.dropbox.com/s/s01kefaks4u6g1f/small_ces2020%20Codebook.docx?dl=0
## Figure 11.1 ####
era <- range_speedread("https://docs.google.com/spreadsheets/d/15Yjcs8tFDyvcqaWw9cPmFIKBuRwqLPnB17VsKhFccJA/edit?usp=sharing")
era <- era %>% mutate(ratified = as.factor(ratified))
era <- era %>%
mutate(fill = frcode(ratified == "1972" ~ "1972",
gg <- ns %>%
mutate(educ = frcode(education <= 3 ~ "Some HS",
education == 4 ~ "HS Grad",
education == 5 ~ "Trade School",
education == 6 ~ "Some College",
education == 7 ~ "2 Yr.",
education == 8 ~ "4 Yr.",
education == 9 ~ "Some Grad.",
education == 10 ~ "Masters",
education == 11 ~ "Doctorate")) %>%
ggg1 <- cces08 %>%
filter(V215 == 1) %>%
cces_race(race) %>%
mutate(vote = CC410) %>%
mutate(vote = frcode(vote == 1 ~ "Republican",
vote == 2 ~ "Democrat",
vote == 3 | vote == 4 | vote == 5 | vote == 6 ~ "Third Party")) %>%
group_by(race) %>%
## Figure 6 - Ideological Space ####
fun <- function(df, var1, var2, var3, weight, yr) {
aaa1 <- df %>%
filter({{var1}} <= 7) %>%
mean_ci({{var1}}, wt = {{weight}}) %>%
mutate(year = yr) %>%
mutate(group = "Yourself")
gg <- gss %>%
filter(year == 2021) %>%
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)
cces20 %>%
filter(pid7 == 5 | pid7 == 6 | pid7 == 7) %>%
cces_trad(religpew) %>%
ct(trad2, wt = commonweight, show = FALSE)
# https://gist.github.com/130761c3a2108c816482553e393134e4
aa <- cces %>%
mutate(ev = case_when(pew_bornagain == 1 ~ 1,
pew_bornagain == 2 ~ 0)) %>%
filter(year == 2010 | year == 2020) %>%
group_by(birthyr, year) %>%
mean_ci(ev, wt = weight, ci = .84)
aa <- aa %>%
mutate(cohorts = frcode(birthyr >= 1919 & birthyr <= 1928 ~ "1925-1929",
birthyr >= 1929 & birthyr <= 1938 ~ "1930-1934",
Five statements - response options range from Strongly Agree to Strongly Disagree
25 = Most Christian Nationalism
5 = Least
1. The federal government should declare the United States a Christian nation
2. The federal government should advocate Christian values
3. The federal government should enforce strict separation of church and state
4. The success of the United States is part of Gods plan
@ryanburge
ryanburge / regregression_grad_methods.R
Last active December 1, 2021 21:39
Regression Walkthrough 12/1/2021
install.packages("jtools")
install.packages("interactions")
install.packages("ggstance")
install.packages("broom.mixed")
library(jtools)
library(interactions)
library(ggstance)
library(broom.mixed)
library(socsci)