Skip to content

Instantly share code, notes, and snippets.

View ryanburge's full-sized avatar

Ryan Burge ryanburge

View GitHub Profile
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)
@ryanburge
ryanburge / 11_22_2021.R
Last active November 10, 2021 22:06
November 11, 2021
gss <- read_csv("https://raw.githubusercontent.com/ryanburge/ct/master/gss_small.csv", guess_max = 25000)
Codebook: https://gssdataexplorer.norc.org/
bball <- read_csv("https://raw.githubusercontent.com/ryanburge/pls2003_sp17/master/bball.csv", guess_max = 25000) %>%
rename(games = g, wins =w, losses = l, runs =r, atbats = ab, hits =h, homeruns =hr, walks = bb, strikeout = so, stolenbase = sb, earnedruns = era)
@ryanburge
ryanburge / assignment_1_fall_2021.R
Created October 30, 2021 15:04
Assignment Number 1 - Graduate Students Fall 2021
library(socsci)
cces20 <- read_csv("https://www.dropbox.com/s/wuixmc67ae786wp/small_ces2020.csv?dl=1")
### Codebook for 2020
https://www.dropbox.com/s/s01kefaks4u6g1f/small_ces2020%20Codebook.docx?dl=0
## Marcus