Recoding a multiple choice item in R using splitstackshape

27 Views Asked by At

I have a multiple choice question: Blah blah blah...Check all that apply. The output is:

> x$Q34
  [1]                                 1,2,8   6,7,8   1,5,6,8         4      
 [10] 2,5     2,6,7                                                          
 [19]                         6                               4              
 [28] 2,4,6,8                                                                
 [37]                                                                        
 [46]  

Basically, the item contains all the choices that the question asked. What I want is: x$Q34 with levels, 1-9, with 9 being "Selected more than one answer." Does that make sense?

I have to split each choice out, and then recombine them. I have considered using the splitstackshape package. Splitstackshape code I have is:

library(splitstackshape)
x <- cSplit(x, "Q34",",")
0

There are 0 best solutions below