I'm undertaking a data analysis of the 2017 General Election using the BES Survey. I need to test whether people who identify as religious are more likely to vote for a certain party, but the survey question lists each religion seperately?
How do I combine these answers together to have one label for all religions?
So far I have the following which gives me a breakdown of each party, voting for Conservative and Other but I need it to be only two categories, 'No Religion' and 'All Religions'.
bes17f <- read_spss("bes_f2f_2017_v1.5.sav") bes17f <- as_factor(bes17f) %>% droplevels() descriptives(bes17f, vars=c(b02, y06), freq = TRUE, bar = TRUE) bes17f <- bes17f %>% mutate( vote17 = recode(b02, "Don`t know"=NA_character_, "Don't know"=NA_character_, "Refused"=NA_character_, "Not stated" = NA_character_, "Other" = NA_character_, "NA" = NA_character_, ), Religion17 = recode(y06, "Don`t know"=NA_character_, "Don't know"=NA_character_, "No religion"=NA_character_, "Refusal" = NA_character_, ) ) bes17f <- bes17f %>% mutate(vote17_simple = fct_other(vote17, keep=c("Conservatives"))) bes17f %>% drop_na(Religion17) %>% drop_na(vote17_simple) %>% ggplot(aes(x=Religion17)) + geom_bar(position="fill", aes(fill=vote17_simple)) + theme(axis.text.x = element_text(angle = 20, hjust = 1)) + scale_y_continuous(labels = percent)
Thanks in advance!