I have a survey database at user level, one of the fields has several multiple choices that the user has selected. Example
col1 | col2
ID1 | a, b, c
ID2 | c, f
ID3 | g, k, z
I want to reshape the file as follows using R:
col1| col2(a)| col3(b)| col4(c)| col5(f)| col6(g)| col7(k)| col8(z)**
ID1 | 1 | 1 | 1 | 0 | 0 | 0 | 0
ID2 | 0 | 0 | 1 | 1 | 0 | 0 | 0
ID3 | 0 | 0 | 0 | 0 | 1 | 1 | 1
please note: I don't know how many distinct values are existing in the original multiple choice field.
Thanks