Skip to content

Instantly share code, notes, and snippets.

Ryan Burge ryanburge

Block or report user

Report or block ryanburge

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ryanburge
ryanburge / reltradv2.R
Created Jun 25, 2019
Reltrad Attempt.
View reltradv2.R
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",
@ryanburge
ryanburge / heat_maps_ed_att.R
Last active Jun 21, 2019
Education and Church Attendance Heat Maps
View heat_maps_ed_att.R
### White Evan Heat Map ####
graph <- cces18 %>%
filter(evangelical == 1) %>%
filter(race == 1) %>%
mutate(att = frcode(pew_churatd == 6 ~ "Never",
pew_churatd == 5 ~ "Seldom",
pew_churatd == 4 ~ "Yearly",
pew_churatd == 3 ~ "Monthly",
pew_churatd == 2 ~ "Weekly",
@ryanburge
ryanburge / polarized_abort.R
Last active Jun 10, 2019
Polarized Abortion
View polarized_abort.R
graph <- gss %>%
mutate(any = car::recode(abany, "1=1; 2=0; else = NA")) %>%
mutate(pid2 = car::recode(partyid, "0:2 = 'Democrat'; 4:6 = 'Republican'; else = NA")) %>%
group_by(year, pid2) %>%
mean_ci(any) %>%
na.omit()
graph %>%
ggplot(., aes(x = year, y = mean, group = pid2, color = pid2)) +
View atheist_therm.R
## Feeling Therms #####
anes12 <- read_dta("anes_timeseries_2012_Stata12.dta")
anes <- anes %>%
mutate(bagain = car::recode(V161263, "1=1; else=0")) %>%
mutate(prot = car::recode(anes$V161247a, "1=1; else =0")) %>%
mutate(baprot = bagain + prot) %>%
@ryanburge
ryanburge / djupe_woke.R
Last active May 25, 2019
VSG Blacks Deserve More or Less
View djupe_woke.R
graph <- tibble::tribble(
~bab, ~ba16f, ~mean, ~sd, ~n, ~level, ~se, ~lower, ~upper, ~year,
"No", "0", 1.997, 0.888342, 5586, 0.05, 0.011886, 1.974034, 2.020635, 2011,
"No", "1", 1.777, 0.935648, 328, 0.05, 0.051663, 1.675319, 1.878584, 2011,
"Yes", "0", 2.015, 0.969264, 234, 0.05, 0.063363, 1.890163, 2.139837, 2011,
"Yes", "1", 1.86, 0.890131, 1851, 0.05, 0.02069, 1.819295, 1.90045, 2011,
"No", "0", 2.273, 1.030418, 5586, 0.05, 0.013787, 2.246446, 2.300501, 2016,
"No", "1", 1.917, 1.012122, 328, 0.05, 0.055885, 1.806727, 2.026606, 2016,
"Yes", "0", 2.276, 1.071907, 234, 0.05, 0.070073, 2.137644, 2.413758, 2016,
"Yes", "1", 1.999, 0.999094, 1851, 0.05, 0.023222, 1.953852, 2.044941, 2016
@ryanburge
ryanburge / cces_interaction.R
Created May 22, 2019
CCES PolAct Interaction
View cces_interaction.R
cces16 <- cces16 %>%
mutate(att = recode(pew_churatd, "1=6; 2=5; 3=4; 4=3; 5=2; 6=1; else = NA")) %>%
mutate(college = car::recode(educ, "1:4=0; 5:6=1; else = NA")) %>%
mutate(meet = recode(CC16_417a_1, "1=1; else =0")) %>%
mutate(sign = recode(CC16_417a_2, "1=1; else =0")) %>%
mutate(vol = recode(CC16_417a_3, "1=1; else =0")) %>%
mutate(money = recode(CC16_417a_4, "1=1; else =0")) %>%
mutate(blood = recode(CC16_417a_5, "1=1; else =0")) %>%
mutate(activity = meet + sign + vol + money + blood) %>%
mutate(den = case_when(religpew == 1 & religpew_protestant !=3 ~ "Denom",
@ryanburge
ryanburge / freethought.R
Last active May 20, 2019
Freethought Election
View freethought.R
## Hex Map of Nones ####
cces18 <- read_dta("D://cces18.dta")
www <- cces18 %>%
mutate(nones = car::recode(religpew, "9:11=1; else =0")) %>%
mutate(state = to_factor(inputstate)) %>%
group_by(state) %>%
View ggpage_pence_taylor.R
library(socsci)
library(ggpage)
library(rvest)
library(tidytext)
source("D://theme.R")
get_text <- function(url) {
url %>%
read_html() %>%
@ryanburge
ryanburge / std_dev.R
Created May 15, 2019
Standard Deviation Nones
View std_dev.R
rnorm2 <- function(n,mean,sd) { mean+sd*scale(rnorm(n)) }
whtevan <- rnorm2(100000, 5.13, 1.99)
oevan <- rnorm2(100000, 3.16, 2.13)
whtml <- rnorm2(100000, 4.21, 2.28)
bprot <- rnorm2(100000, 2.00, 1.56)
whtcath <- rnorm2(100000, 4.20, 2.24)
ocath <- rnorm2(100000, 3.01, 2.01)
ath <- rnorm2(100000, 2.42, 1.63)
@ryanburge
ryanburge / abortion_election_GSS.R
Last active May 10, 2019
Abortion by Election Periods GSS
View abortion_election_GSS.R
regg <- gss %>%
mutate(pid7 = car::recode(partyid, "7:99 =NA")) %>%
mutate(pid3 = car::recode(pid7, "0:2 = 'Democrat'; 4:6 = 'Republican'; else = NA")) %>%
mutate(pid3 = as.factor(pid3)) %>%
mutate(male = car::recode(sex, "1=1; 2=0; else = NA")) %>%
mutate(male = as.factor(male)) %>%
mutate(years = as.factor(year)) %>%
mutate(white = car::recode(race, "1=1; else =0")) %>%
mutate(white = as.factor(white)) %>%
mutate(ab1 = car::recode(abdefect, "1=0; 2=1; else = NA")) %>%
You can’t perform that action at this time.