Skip to content

Instantly share code, notes, and snippets.

@ryanburge ryanburge/dfp_gop_ba.R
Last active Feb 2, 2019

Embed
What would you like to do?
Are Born-Again Republicans Different than Republicans in General?
library(socsci)
library(car)
source("D://theme.R")
dfp <- read_csv("D://dfp/data.csv")
## Specific Issues ####
ddd1 <- dfp %>% mean_fun(ICE, "Abolish ICE")
ddd2 <- dfp %>% mean_fun(BAIL_item, "End Cash Bail")
ddd3 <- dfp %>% mean_fun(WELTEST, "Drug Test for Welfare")
ddd4 <- dfp %>% mean_fun(PUBLICINT, "Create Public Internet Co.")
ddd5 <- dfp %>% mean_fun(GREENJOB, "Give Green Jobs to Unemployed")
ddd6 <- dfp %>% mean_fun(POLFEE, "Charge Pollution Fees")
ddd7 <- dfp %>% mean_fun(PUBLICGEN, "Govt. Produce Generic Drugs")
ddd8 <- dfp %>% mean_fun(BOND, "Savings Bond for New Babies")
ddd9 <- dfp %>% mean_fun(FREECOLL, "Free College for All")
ddd10 <- dfp %>% mean_fun(WEALTH, "Wealth Tax")
ddd11 <- dfp %>% mean_fun(AVR, "Automatic Voter Registration")
ddd12 <- dfp %>% mean_fun(M4A, "Medicare for All")
ddd13 <- dfp %>% mean_fun(MARREP, "Marijuana Tax for Drug Treatment")
ddd14 <- dfp %>% mean_fun(MARAM, "Release Marijuana Related Prisoners")
ddd15 <- dfp %>% mean_fun(MARLEG, "Legalizing Marijuana")
ddd16 <- dfp %>% mean_fun(YEMEN, "End US Support of Saudi Arabia in Yemen")
ddd17 <- dfp %>% mean_fun(SOLITARY, "End Solitary Confinement")
graph <- bind_df("ddd")
graph %>%
ggplot(., aes(y=mean, x= fct_reorder(issue, mean), color = group)) +
geom_point(position=position_dodge(width=0.5), size =4) +
geom_errorbar(aes(ymin = lower, ymax=upper), position=position_dodge(0.5), size = 1, width = .25) +
coord_flip() +
theme_gg("Abel") +
labs(title = "Where Do White Evangelicals Diverge from Republicans?", x = "", y = "", caption = "Data: Data for Progress (2018)") +
scale_y_continuous(limits = c(0.85,5.25), breaks = c(1,2,3,4,5), labels = c("Strongly\nDisagree", "Somewhat\nDisagree", "Neither Agree\nor Disagree", "Somewhat\nAgree", "Strongly\nAgree")) +
scale_color_jama() +
theme(legend.position = "bottom") +
theme(legend.title=element_blank()) +
theme(text=element_text(size=28, family="font")) +
ggsave("D://dfp/all_issues.png", height = 8, width =18)
## Racial Animus ####
rrr1 <- dfp %>% mean_fun(GENERATIONS, "Generations of Slavery Created Conditions\nThat Make It Difficult for AAs to Get Ahead")
rrr2 <- dfp %>% mean_fun(FAVORS, "Italy, Irish, Jewish Immigrants Overcame\nPrejudice, Black Should Do the Same")
rrr3 <- dfp %>% mean_fun(INSTITUTION, "White People Have Advantages\nBecause of their Skin Color")
rrr4 <- dfp %>% mean_fun(SYSTEM, "Racial Problems in the U.S.\n Are Rare, Isolated Situations")
rrr5 <- dfp %>% mean_fun(EMPATHY, "I am Angry That Racism Exists")
graph <- bind_df("rrr")
graph %>%
ggplot(., aes(y=mean, x= fct_reorder(issue, mean), color = group)) +
geom_point(position=position_dodge(width=0.5), size =4) +
geom_errorbar(aes(ymin = lower, ymax=upper), position=position_dodge(0.5), size = 1, width = .25) +
coord_flip() +
theme_gg("Abel") +
labs(title = "Racial Animus Questions", x = "", y = "", caption = "Data: Data for Progress (2018)") +
scale_y_continuous(limits = c(0.85,5.25), breaks = c(1,2,3,4,5), labels = c("Strongly\nDisagree", "Somewhat\nDisagree", "Neither Agree\nor Disagree", "Somewhat\nAgree", "Strongly\nAgree")) +
scale_color_jama() +
theme(legend.position = "bottom") +
theme(legend.title=element_blank()) +
theme(text=element_text(size=28, family="font")) +
ggsave("D://dfp/animus_issues.png", height = 8, width =18)
## Fear of Demographic Changes ####
mean_fun <- function(df, var, ques){
var <- enquo(var)
df1 <- df %>%
filter(religpew == 1) %>%
filter(pew_bornagain ==1) %>%
filter(race ==1) %>%
mutate(var = car::recode(!! var, "1=5; 2=4; 3=3; 4=2; 5=1; else = NA")) %>%
mean_ci(var) %>%
mutate(group = "White BA Prots.") %>%
mutate(issue = ques)
df2 <- df %>%
filter(pid3 ==2) %>%
filter(pew_bornagain !=1) %>%
# filter(race ==1) %>%
mutate(var = car::recode(!! var, "1=5; 2=4; 3=3; 4=2; 5=1; else = NA")) %>%
mean_ci(var) %>%
mutate(group = "Not Born Again Republicans") %>%
mutate(issue = ques)
df3 <- df %>%
filter(pid3 ==2) %>%
mutate(var = car::recode(!! var, "1=5; 2=4; 3=3; 4=2; 5=1; else = NA")) %>%
mean_ci(var) %>%
mutate(group = "Republican Sample") %>%
mutate(issue = ques)
df4 <- df %>%
filter(religpew ==1) %>%
filter(pew_bornagain ==1) %>%
filter(race ==1) %>%
filter(pid3 ==2) %>%
mutate(var = car::recode(!! var, "1=5; 2=4; 3=3; 4=2; 5=1; else = NA")) %>%
mean_ci(var) %>%
mutate(group = "White BA Republicans") %>%
mutate(issue = ques)
bind_rows(df1, df2, df3, df4)
}
eee1 <- dfp %>% mean_fun(CUSTOMS, "Newcomers Threaten\nAmerican Customs")
eee2 <- dfp %>% mean_fun(SPEAK, "Bothers Me When Someone\nDoesn't Speak English")
eee3 <- dfp %>% mean_fun(ENRICH, "Exposure To Different Cultures\n Will Enrich Americans")
eee4 <- dfp %>% mean_fun(SERVICES, "Demographic Change Will\nStrain Govt. Services")
eee5 <- dfp %>% mean_fun(JOBS, "Growth in PoC Will\nLead to Jobs Shortage")
graph <- bind_df("eee")
graph %>%
ggplot(., aes(y=mean, x= fct_reorder(issue, mean), color = group)) +
geom_point(position=position_dodge(width=0.5), size =4) +
geom_errorbar(aes(ymin = lower, ymax=upper), position=position_dodge(0.5), size = 1, width = .25) +
coord_flip() +
theme_gg("Abel") +
labs(title = "Fear of Demographic Changes", x = "", y = "", caption = "Data: Data for Progress (2018)") +
scale_y_continuous(limits = c(0.85,5.25), breaks = c(1,2,3,4,5), labels = c("Strongly Disagree", "Somewhat Disagree", "Neither Agree\nor Disagree", "Somewhat Agree", "Strongly Agree")) +
scale_color_jama() +
theme(legend.position = "bottom") +
theme(legend.title=element_blank()) +
theme(text=element_text(size=28, family="font")) +
ggsave("D://dfp/race_issue.png", height = 8, width =16)
## Race Lazy Intelligent #####
mean_fun <- function(df, var, ques){
var <- enquo(var)
df1 <- df %>%
filter(religpew == 1) %>%
filter(pew_bornagain ==1) %>%
filter(race ==1) %>%
mean_ci(!! var) %>%
mutate(group = "White BA Prots.") %>%
mutate(issue = ques)
df2 <- df %>%
filter(pid3 ==2) %>%
filter(pew_bornagain !=1) %>%
# filter(race ==1) %>%
mean_ci(!! var) %>%
mutate(group = "Not Born Again Republicans") %>%
mutate(issue = ques)
df3 <- df %>%
filter(pid3 ==2) %>%
mean_ci(!! var) %>%
mutate(group = "Republican Sample") %>%
mutate(issue = ques)
df4 <- df %>%
filter(religpew ==1) %>%
filter(pew_bornagain ==1) %>%
filter(race ==1) %>%
filter(pid3 ==2) %>%
mean_ci(!! var) %>%
mutate(group = "White BA Republicans") %>%
mutate(issue = ques)
bind_rows(df1, df2, df3, df4)
}
ggg1 <- dfp %>% mean_fun(LAZY_Whites, "Whites")
ggg2 <- dfp %>% mean_fun(LAZY_Blacks, "Blacks")
ggg3 <- dfp %>% mean_fun(LAZY_Latinos, "Latinos")
graph <- bind_df("ggg")
graph$issue <- factor(graph$issue, levels = c("Whites", "Blacks", "Latinos"))
g1 <- graph %>%
ggplot(., aes(y=mean, x= fct_rev(issue), color = group)) +
geom_point(position=position_dodge(width=0.5), size =4) +
geom_errorbar(aes(ymin = lower, ymax=upper), position=position_dodge(0.5), size = 1, width = .25) +
coord_flip() +
theme_gg("Abel") +
labs(title = "How Hardworking Are These Groups?", x = "", y = "", caption = "") +
scale_y_continuous(limits = c(0.85,7.25), breaks = c(1,2,3,4,5,6,7), labels = c("Very\nLazy", "Lazy", "Somewhat\nLazy", "Neither", "Somewhat\nHardworking", "Hardworking", "Very\nHardworking")) +
scale_color_jama() +
theme(legend.position = "bottom") +
theme(legend.title=element_blank()) +
theme(text=element_text(size=28, family="font")) +
ggsave("D://dfp/lazy.png", height = 8, width =18)
mean_fun_rev <- function(df, var, ques){
var <- enquo(var)
df1 <- df %>%
filter(religpew == 1) %>%
filter(pew_bornagain ==1) %>%
filter(race ==1) %>%
mutate(var = recode(!! var, "1=7; 2=6; 3=5; 4=4; 5=3; 6=2; 7=1")) %>%
mean_ci(var) %>%
mutate(group = "White Evangelicals") %>%
mutate(issue = ques)
df2 <- df %>%
filter(pid3 ==2) %>%
filter(pew_bornagain !=1) %>%
# filter(race ==1) %>%
mutate(var = recode(!! var, "1=7; 2=6; 3=5; 4=4; 5=3; 6=2; 7=1")) %>%
mean_ci(var) %>%
mutate(group = "Not Born Again Republicans") %>%
mutate(issue = ques)
df3 <- df %>%
filter(pid3 ==2) %>%
mutate(var = recode(!! var, "1=7; 2=6; 3=5; 4=4; 5=3; 6=2; 7=1")) %>%
mean_ci(var) %>%
mutate(group = "Republican Sample") %>%
mutate(issue = ques)
df4 <- df %>%
filter(religpew ==1) %>%
filter(pew_bornagain ==1) %>%
filter(race ==1) %>%
filter(pid3 ==2) %>%
mutate(var = recode(!! var, "1=7; 2=6; 3=5; 4=4; 5=3; 6=2; 7=1")) %>%
mean_ci(var) %>%
mutate(group = "White BA Republicans") %>%
mutate(issue = ques)
bind_rows(df1, df2, df3, df4)
}
ggg1 <- dfp %>% mean_fun_rev(INTELLIGENT_Whites, "Whites")
ggg2 <- dfp %>% mean_fun_rev(INTELLIGENT_Blacks, "Blacks")
ggg3 <- dfp %>% mean_fun_rev(INTELLIGENT_Latinos, "Latinos")
graph <- bind_df("ggg")
graph$issue <- factor(graph$issue, levels = c("Whites", "Blacks", "Latinos"))
g2 <- graph %>%
ggplot(., aes(y=mean, x= fct_rev(issue), color = group)) +
geom_point(position=position_dodge(width=0.5), size =4) +
geom_errorbar(aes(ymin = lower, ymax=upper), position=position_dodge(0.5), size = 1, width = .25) +
coord_flip() +
theme_gg("Abel") +
labs(title = "How Intelligent Are These Groups?", x = "", y = "", caption = "Data: Data for Progress (2018)") +
scale_y_continuous(limits = c(0.85,7.25), breaks = c(1,2,3,4,5,6,7), labels = c("Very\nUnintelligent", "Unintelligent", "Somewhat\nUnintelligent", "Neither", "Somewhat\nIntelligent", "Intelligent", "Very\nIntelligent")) +
scale_color_jama() +
theme(legend.position = "bottom") +
theme(legend.title=element_blank()) +
theme(text=element_text(size=28, family="font")) +
ggsave("D://dfp/intel.png", height = 8, width =18)
library(patchwork)
all <- g1 + g2 + plot_layout(ncol = 1)
ggsave("D://dfp/patch_intel_lazy.png", all, height = 10, width =14)
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.