Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Four Years of White Christians
regg <- gss %>%
mutate(rep = case_when(partyid == 4 | partyid == 5 | partyid == 6 ~ 1, TRUE ~ 0)) %>%
mutate(white = case_when(race == 1 ~ 1, TRUE ~ 0)) %>%
mutate(whtevan = frcode(race == 1 & evangelical == 1 ~ "White Evangelical",
race == 1 & mainline == 1 ~ "White Mainline",
race == 1 & catholic == 1 ~ "White Catholic", TRUE ~ "Everyone Else")) %>%
mutate(male = case_when(sex == 1 ~ 1, TRUE ~ 0)) %>%
mutate(yrs = frcode(year >= 1972 & year <= 1979 ~ "1970's",
year >= 1980 & year <= 1989 ~ "1980's",
year >= 1990 & year <= 1999 ~ "1990's",
year >= 2000 & year <= 2009 ~ "2000's",
year >= 2010 ~ "2010's")) %>%
select(yrs, rep, whtevan, educ, age, educ, attend, male, white)
reg1 <- glm(rep ~ attend*yrs*whtevan + educ + male + white, data = regg, family = "binomial")
gg2 <- interact_plot(reg1, pred= attend, modx = yrs, mod2 = whtevan, int.width = .76, interval = TRUE, mod2.labels = c("White Evangelical", "White Mainline", "White Catholic", "Everyone Else"), modx.labels = c("1970's", "1980's", "1990's", "2000's", "2010's"))
gg2 +
labs(x = "Church Attendance", y = "Predicted Shared Identifying as Republican", title = "The Relationship Between Attendance and Republican ID Over Time", caption = "@ryanburge\nData: GSS 1972-2018", subtitle = "") +
theme_gg("Abel") +
y_pct() +
scale_x_continuous(breaks = c(0, 2, 4, 6, 8), labels = c("Never", "Once\na Year", "Once\na Month", "Nearly\nEvery\nWeek", "More\nthan\nOnce\na Week")) +
theme(legend.position = "bottom") +
scale_color_tableau() +
scale_fill_tableau() +
theme(panel.spacing = unit(2, "lines")) +
ggsave("E://gss_interact_time_rep_overway.png", type = "cairo-png")
### 1970's ####
regg70 <- regg %>%
filter(yrs == "1970's")
reg1 <- glm(rep ~ attend*whtevan + educ + male + white, data = regg70, family = "binomial")
gg2 <- interact_plot(reg1, pred= attend, modx = whtevan, int.width = .76, interval = TRUE, modx.labels = c("White Evangelical", "White Mainline", "White Catholic", "Everyone Else"))
gg2 +
labs(x = "Church Attendance", y = "Predicted Shared Identifying as Republican", title = "The Relationship Between Attendance and Republican ID", caption = "@ryanburge\nData: GSS 1972-1979", subtitle = "1970's") +
theme_gg("Abel") +
y_pct() +
scale_x_continuous(breaks = c(0, 2, 4, 6, 8), labels = c("Never", "Once\na Year", "Once\na Month", "Nearly\nEvery\nWeek", "More\nthan\nOnce\na Week")) +
theme(legend.position = "bottom") +
scale_color_tableau() +
scale_fill_tableau() +
theme(panel.spacing = unit(2, "lines")) +
ggsave("E://gss_interact_1970s.png", type = "cairo-png")
### 1980's ####
regg80 <- regg %>%
filter(yrs == "1980's")
reg1 <- glm(rep ~ attend*whtevan + educ + male + white, data = regg80, family = "binomial")
gg2 <- interact_plot(reg1, pred= attend, modx = whtevan, int.width = .76, interval = TRUE, modx.labels = c("White Evangelical", "White Mainline", "White Catholic", "Everyone Else"))
gg2 +
labs(x = "Church Attendance", y = "Predicted Shared Identifying as Republican", title = "The Relationship Between Attendance and Republican ID", caption = "@ryanburge\nData: GSS 1980-1989", subtitle = "1980's") +
theme_gg("Abel") +
y_pct() +
scale_x_continuous(breaks = c(0, 2, 4, 6, 8), labels = c("Never", "Once\na Year", "Once\na Month", "Nearly\nEvery\nWeek", "More\nthan\nOnce\na Week")) +
theme(legend.position = "bottom") +
scale_color_tableau() +
scale_fill_tableau() +
theme(panel.spacing = unit(2, "lines")) +
ggsave("E://gss_interact_1980s.png", type = "cairo-png")
### 2000's ####
regg00 <- regg %>%
filter(yrs == "2000's")
reg1 <- glm(rep ~ attend*whtevan + educ + male + white, data = regg00, family = "binomial")
gg2 <- interact_plot(reg1, pred= attend, modx = whtevan, int.width = .76, interval = TRUE, modx.labels = c("White Evangelical", "White Mainline", "White Catholic", "Everyone Else"))
gg2 +
labs(x = "Church Attendance", y = "Predicted Shared Identifying as Republican", title = "The Relationship Between Attendance and Republican ID", caption = "@ryanburge\nData: GSS 2000-2009", subtitle = "2000's") +
theme_gg("Abel") +
y_pct() +
scale_x_continuous(breaks = c(0, 2, 4, 6, 8), labels = c("Never", "Once\na Year", "Once\na Month", "Nearly\nEvery\nWeek", "More\nthan\nOnce\na Week")) +
theme(legend.position = "bottom") +
scale_color_tableau() +
scale_fill_tableau() +
theme(panel.spacing = unit(2, "lines")) +
ggsave("E://gss_interact_2000s.png", type = "cairo-png")
### 2010's ####
regg10 <- regg %>%
filter(yrs == "2010's")
reg1 <- glm(rep ~ attend*whtevan + educ + male + white, data = regg10, family = "binomial")
gg2 <- interact_plot(reg1, pred= attend, modx = whtevan, int.width = .76, interval = TRUE, modx.labels = c("White Evangelical", "White Mainline", "White Catholic", "Everyone Else"))
gg2 +
labs(x = "Church Attendance", y = "Predicted Shared Identifying as Republican", title = "The Relationship Between Attendance and Republican ID", caption = "@ryanburge\nData: GSS 2010-2018", subtitle = "2010's") +
theme_gg("Abel") +
y_pct() +
scale_x_continuous(breaks = c(0, 2, 4, 6, 8), labels = c("Never", "Once\na Year", "Once\na Month", "Nearly\nEvery\nWeek", "More\nthan\nOnce\na Week")) +
theme(legend.position = "bottom") +
scale_color_tableau() +
scale_fill_tableau() +
theme(panel.spacing = unit(2, "lines")) +
ggsave("E://gss_interact_2010s.png", type = "cairo-png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.