I have a data set looks like, dat. I want to create one new variable (newVar) with values 1 through 4 using the Q1 through Q6 in R. Can anyone help how to do this, please?
newVar of 1: If any variable in Q1 through Q6 = "A"
newVar of 2: **If none of variables in Q1 through Q6 = "A", and** If any variable in Q59_1 through Q6= "B"
newVar of 3: **If none of variables in Q1 through Q6 = "A" or "B", and** If any variable in Q1 through Q6= "C"
newVar of 4: If none of variables in Q1 through Q6 = "A" or "B" or "C" , and**strong text** If any variable in Q1 through Q6= "D"
dat = data.frame(Q1 = c("A","D","B","A","D","C","B"),
Q2 = c("C","A","B","A","C","C","B"),
Q3 = c("B","D","D","A","B","C","A"),
Q4 = c("A","C","A","D","B","D","B"),
Q5 = c("C","D","D","A","A","C","B"),
Q6 = c("D","B","A","A","C","C","A"),
Q7 = c("5","1","2","2","4","0","3"),
Q8 = c("T","U","O","O","Z","W","Y"),
Q9 = c("X","T","V","P","I","U","Y"))
Additional comment: I actually need all the conditions especially the bold parts (If none of variables in ...) such as NewVar 2: If none of variables in Q1 through Q6 = "A", and If any variable in Q59_1 through Q6= "B" 3: If none of variables in Q1 through Q6 = "A" or "B", and If any variable in Q1 through Q6= "C" 4: If none of variables in Q1 through Q6 = "A" or "B" or "C" , and If any variable in Q1 through Q6= "D"