I have a survey dataset that includes self-reported ethnicity. Participants were allowed to select as many ethnicities as they wanted to. The data structure looks like this:
Hispanic English Indian
1 NA NA
NA 1 NA
NA NA 1
NA 1 1
1 1 1
What I want to do is create a new categorical ethnicity variable where the column names take the place of the 1s above. In addition, if someone selected more than one ethnicity, then the categorical ethnicity variable should include both, like this:
Hispanic English Indian Ethnicity
1 NA NA Hispanic
NA 1 NA English
NA NA 1 Indian
NA 1 1 English_Indian
1 1 1 Hispanic_English_Indian