I have likert scale responses ranging from 1:7 where 8 is "don't know". I'd like to recode 1:3, 4, 5:7 as a new variable where instead of a vector with 8 different responses, I have a new variable that consolidates 1:3, 4, and 5:7 and ignores "don't know" responses. I want to call it "pid3." The vector comes from imported polling data. It is called "pid7." It is very long so I cannot manually re-type it. Sorry- this is my first time asking a question here. I am not fluent in R.
library(dplyr)
class(pop$pid7)
pid3 <- data.frame(x = c("DEMOCRAT", "INDEPENDENT", "REPUBLICAN"))
pid7 <- recode(pop$pid7, x_recoded = recode(x, "DEMOCRAT" = 1:3, "INDEPENDENT" = 4, "REPUBLICAN" = 5:7, "NA"= 8))
dplyr::recode(pop$pid7, "DEMOCRAT" = 1,2,3, "INDI" = 4, "REPUBLICAN" = 5,6,7, "NA" = 8)
these are the things I've tried. I don't understand what order I need to do things in.