Skip to content

Instantly share code, notes, and snippets.

Avatar

Ryan Burge ryanburge

View GitHub Profile
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.
View RStudio_ct_untitled_51EA07C1
gg <- cces18 %>%
mutate(trad2 = frcode(evangelical == 1 & race == 1 ~ "White Evangelical",
evangelical == 1 & race != 1 ~ "Non-White Evangelical",
mainline == 1 ~ "Mainline",
religpew == 1 & race == 2 ~ "Black Protestant",
catholic == 1 & race == 1 ~ "White Catholic",
catholic == 1 & race != 1 ~ "Non-White Catholic",
religpew == 3 ~ "Mormon",
religpew == 4 ~ "Orthodox",
religpew == 5 ~ "Jewish",
@ryanburge
ryanburge / ns_bind.R
Created May 2, 2020
Nationscape Bind
View ns_bind.R
ns <- read_dta("C://ns/ns20190718.dta") %>% mutate(week = 0718)
ns1 <- read_dta("C://ns/ns20190725.dta") %>% mutate(week = 0725)
ns2 <- read_dta("C://ns/ns20190801.dta") %>% mutate(week = 0801)
ns3 <- read_dta("C://ns/ns20190808.dta") %>% mutate(week = 0808)
ns4 <- read_dta("C://ns/ns20190815.dta") %>% mutate(week = 0815)
ns5 <- read_dta("C://ns/ns20190822.dta") %>% mutate(week = 0822)
ns6 <- read_dta("C://ns/ns20190829.dta") %>% mutate(week = 0829)
ns7 <- read_dta("C://ns/ns20190905.dta") %>% mutate(week = 0908)
ns8 <- read_dta("C://ns/ns20190912.dta") %>% mutate(week = 0912)
ns9 <- read_dta("C://ns/ns20190919.dta") %>% mutate(week = 0919)
View RStudio_ct_selection_untitled_6AC9F703
issue_fun <- function(df, var, name){
df %>%
mutate(evan = case_when(is_evangelical == 1 ~ 1, TRUE ~ 0)) %>%
mutate(prot = case_when(religion == 1 ~ 1, TRUE ~ 0)) %>%
mutate(white = case_when(race_ethnicity == 1 ~ 1, TRUE ~ 0)) %>%
mutate(add = evan + prot + white) %>%
mutate(rep = case_when(pid3 == 2 ~ 1, TRUE ~ 0)) %>%
View IG_palettes.R
fill4_1 <- function(){
scale_fill_manual(values = c("#2B5B6C", "#C7CFAC", "#FCFAF1", "#E34F33"))
}
color4_1 <- function(){
scale_color_manual(values = c("#2B5B6C", "#C7CFAC", "#FCFAF1", "#E34F33"))
View older_nones_rip.R
### Graph 1 ####
graph <- cces %>%
mutate(age2 = frcode(age >= 18 & age <= 35 ~ "18-35",
age >= 36 & age <= 44 ~ "36-44",
age >= 45 & age <= 54 ~ "45-54",
age >= 55 & age <= 64 ~ "55-64",
age >= 65 ~ "65+")) %>%
filter(religion == 9 | religion == 10 | religion == 11) %>%
group_by(year) %>%
@ryanburge
ryanburge / calendar_graph.R
Last active Apr 23, 2020
Making a calendar
View calendar_graph.R
## Packages ##
library(socsci) #remotes::install_github("ryanburge/socsci")
library(ggcal) #remotes::install_github("jayjacobs/ggcal")
library(showtext)
library(ggthemes)
library(ggsci)
library(lubridate)
## My theme function ###
You can’t perform that action at this time.