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:
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):
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!