Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Burge ryanburge

View GitHub Profile
@ryanburge
ryanburge / wwc_no_college_pres_vote.R
Last active Apr 14, 2021
White Working Class without College
View wwc_no_college_pres_vote.R
library(tidyverse)
library(socsci) #remotes::install_github("ryanburge/socsci")
median(cces08$V246, na.rm = TRUE) #8
yyy1 <- cces08 %>%
filter(V246 <= 7) %>%
View RStudio_ct_selection_untitled_6FA05261
arr <- read_csv("D://arrivals.csv")
arr <- arr %>%
mutate(name = replace_na(`Basic data and indicators`, "REMOVE")) %>%
select(-`Basic data and indicators`)
tot <- arr %>%
filter(X3 == "Total arrivals" | name != "REMOVE") %>%
relocate(name)
@ryanburge
ryanburge / grad_class_mean_sd.R
Created Nov 18, 2020
Graduate Class for 11/18/2020
View grad_class_mean_sd.R
## Grab the data here:
pop <- read.csv("https://raw.githubusercontent.com/ryanburge/pls2003_sp17/master/population.csv") %>%
mutate(height = round(height, 1)) %>%
mutate(weight = round(weight, 1))
### More data here:
bball <- read_csv("https://raw.githubusercontent.com/ryanburge/pls2003_sp17/master/bball.csv", guess_max = 25000)
bball <- bball %>%
View cces_2020_reltrad.R
library(tidyverse)
# library(haven)
library(car)
# cces20 <- read_dta("D://cces/data/cces20.dta")
cces20 <- cces20 %>%
mutate(white = car::recode(race, "1=1; else=0")) %>%
@ryanburge
ryanburge / gist:4ac9e7454f04c82e7ae6ef1a2f5b2ae0
Last active Nov 11, 2020
Assignment #1 Graduate Students Fall 2020
View gist:4ac9e7454f04c82e7ae6ef1a2f5b2ae0
TUTORIAL: https://rpubs.com/ryanburge/fall_2019
For each answer, please provide your syntax and a written description of the answer.
This will be due on November 22, 2020 at 8 PM in the Dropbox.
You can take a look at the variable names by typing:
gss %>% glimpse()
@ryanburge
ryanburge / grad_class_day1.R
Last active Oct 21, 2020
Grad Class Day 1
View grad_class_day1.R
1. Go to http://104.248.127.81:8787/auth-sign-in
2. User: your first name (no caps)
3. Password: your last name (no caps)
Type this:
library(socsci)
Paste this in to grab data:
cces <- read_csv("https://raw.githubusercontent.com/ryanburge/cces/master/CCES%20for%20Methods/small_cces.csv")
View pid3_trad2_daca.R
graph <- cces18 %>%
cces_trad(religpew) %>%
mutate(pid3 = frcode(pid3 == 1 ~ "Dem",
pid3 == 3 ~ "Ind",
pid3 == 2 ~ "Rep")) %>%
mutate(daca = case_when(CC18_322b == 1 ~ 1,
CC18_322b == 2 ~ 0)) %>%
group_by(trad2, pid3) %>%
mean_ci(daca)
@ryanburge
ryanburge / jews_pr_epis.R
Last active Jun 8, 2020
Jews, Episcopalians, and Puerto Ricans
View jews_pr_epis.R
cc16 <- cces16 %>%
mutate(group = frcode(religpew_protestant == 7 ~ "Episcopalian",
religpew == 5 ~ "Jewish",
Hispanic_origin_4 == 1~ "Puerto Rican")) %>%
mutate(age = 2016 - birthyr) %>%
select(group, pew_churatd, educ, age, gender, pew_religimp, pew_bornagain, vote = CC16_410a, race, weight = commonweight_vv, income = faminc) %>%
mutate(year = 2016)
cc18 <- cces18 %>%
mutate(group = frcode(religpew_protestant == 7 ~ "Episcopalian",
View gist:10e736390eb7e309ba08fb565857e472
cces18 %>%
mutate(rac1 = case_when(CC18_422e == 1 | CC18_422e == 2 ~ 1,
CC18_422e == 3 | CC18_422e == 4 | CC18_422e == 5 ~ 0)) %>%
mutate(rac2 = case_when(CC18_422f == 4 | CC18_422f == 5 ~ 1,
CC18_422f == 1 | CC18_422f == 2 | CC18_422f == 3 ~ 0)) %>%
mutate(rac3 = case_when(CC18_422g == 4 | CC18_422g == 5 ~ 1,
CC18_422g == 1 | CC18_422g == 2 | CC18_422g == 3 ~ 0)) %>%
mutate(rac4 = case_when(CC18_422h == 1 | CC18_422h == 2 ~ 1,
CC18_422h == 3 | CC18_422h == 4 | CC18_422h == 5 ~ 0)) %>%
mutate(resent = rac1 + rac2 + rac3 + rac4)
View resentment_race.R
## Racial Resentment Index
## Strongly Agree or Somewhat Agree == 1
1. Irish, Italians, Jewish and many other minorities overcame prejudice and worked their way up. Blacks should do the same without any special favors.
## Strongly Agree or Somewhat Agree == 1
2. Generations of slavery and discrimination have created conditions that make it difficult for blacks to work their way out of the lower class.
## Strongly Disagree or Somewhat disagree == 1
3. Over the past few years, blacks have gotten less than they deserve.
## Strongly Disagree or Somewhat disagree == 1
4. Its really a matter of some people not trying hard enough, if blacks would only try harder they could be just as well off as whites.