I have a certain variable going from x_1 up to x_45 (i.e. 45 possible input).
Making a survey, the questioned individuals provide me an double response, selecting 2 of the possible variables. It is also possible to select the same variables twice. Here's reported an example for 3 subjects:
A: 3,8
B: 11,15
C: 9,9
I'd like to create a matrix of 0, 1 and 2 according to the choices of the individuals, where 1 indicate the variable that the subject have selected, 2 indicates that the variable has been selected twice, otherwise the input is 0 if the variable has not been selected.
An example of the matrix I'd like to obtain is reported, as follows (according to the values provided by individuals A, B and C):
Subject,x_1,x_2,x_3,x_4,x_5,x_6,x_7,x_8,x_9,x_10,x_11,x_12,x_13,x_14,x_15
A,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0
B,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1
C,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0
How can I write a code in order to do this for a large number of individuals (e.g. up to 1000 subjects)?
I'd be very grateful if someone could attend to this matter!