I have data collected from a survey. One factor variable is like this:
Column1 Column2 Column3 Column4 Column5
A B C
B C
A B C D E
A C E
C E
B D E
In other words, classes are spread in many different variables. I want to create one binary variable (1 or 0) for each class (A, B, C, D, E). However it’s not clear to me how to do it. How can I do it?
EDIT
The output would be something like this:
A B C D E
1 1 1 0 0
0 1 1 0 0
1 1 1 1 1
1 0 1 0 1
0 0 1 0 1
0 1 0 1 1
1 Answer