mercredi 27 septembre 2017

Breaking up a checkbox column containing multiple answers into separate columns in R

I have multiple checkboxes in a data set that need to be divided. One of these checkbox questions asks about what states someone practices in (thus there are 50 checkbox options) The data is exported in the format below:

ID  q143

1   1,4,6

But I need it in this format (a true/false format for each individual check box (unchecked/checked)

ID   q143_1  q143_2  q143_3  q143_4  q143_5  q143_6

100    1       0       0       1       0        1

Since this is such a large number of columns that need to be made.. any ideas on how to separate this easily? I was thinking if, then statements but I think that would take a while.

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire