Skip to content

Instantly share code, notes, and snippets.

@ryanburge
Last active April 14, 2021 23:04
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/c0ec4d56c12d0cafdacec880ed0f8591 to your computer and use it in GitHub Desktop.
Save ryanburge/c0ec4d56c12d0cafdacec880ed0f8591 to your computer and use it in GitHub Desktop.
White Working Class without College
library(tidyverse)
library(socsci) #remotes::install_github("ryanburge/socsci")
median(cces08$V246, na.rm = TRUE) #8
yyy1 <- cces08 %>%
filter(V246 <= 7) %>%
filter(V211 == 1) %>%
filter(V213 <= 4) %>%
mutate(vote = CC410) %>%
mutate(vote = frcode(vote == 1 ~ "Republican",
vote == 2 ~ "Democrat",
vote == 3 | vote == 4 | vote == 5 | vote == 6 ~ "Third Party")) %>%
ct(vote, wt = V201, show_na = FALSE) %>%
mutate(year = 2008)
median(cces12$faminc, na.rm = TRUE) #6
yyy2 <- cces12 %>%
filter(faminc <= 5) %>%
filter(race == 1) %>%
filter(educ <= 4) %>%
mutate(vote = CC410a) %>%
mutate(vote = frcode(vote == 1 ~ "Democrat",
vote == 2 ~ "Republican",
vote == 4 ~ "Third Party")) %>%
ct(vote, wt = weight_vv_post, show_na = FALSE) %>%
mutate(year = 2012)
median(cces16$faminc, na.rm = TRUE) #7
yyy3 <- cces16 %>%
filter(faminc <= 6) %>%
filter(race == 1) %>%
filter(educ <= 4) %>%
mutate(vote = CC16_410a) %>%
mutate(vote = frcode(vote == 1 ~ "Republican",
vote == 2 ~ "Democrat",
vote == 3 | vote == 4 | vote == 5 | vote == 8 ~ "Third Party")) %>%
ct(vote, wt = commonweight_vv_post, show_na = FALSE) %>%
mutate(year = 2016)
median(cces20$faminc_new, na.rm = TRUE) #7
yyy4 <- cces20 %>%
filter(faminc_new <= 6) %>%
filter(race == 1) %>%
filter(educ <= 4) %>%
mutate(vote = CC20_410) %>%
mutate(vote = frcode(vote == 1 ~ "Democrat",
vote == 2 ~ "Republican",
vote == 4 ~ "Third Party")) %>%
ct(vote, wt = commonpostweight, show_na = FALSE) %>%
mutate(year = 2020)
graph <- bind_df("yyy")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment