How do I separate the answers to a multiple-choice survey question where multiple answers are allowed, in R?

36 Views Asked by At

I have the results of a survey that I carried out and I am unsure of how to deal with the answers to multiple choice questions where several answers are allowed.

For example, say I asked "How do you travel to work?" and one response was "On foot; by car; by bus", how can I separate the individual components of this answer to create a new column where they are all listed?

I want to see which is the most common answer.

I tried the following solution:

test <- str_split(survey$how_travel, ";") 

and this returns a list with a row for each respondent but each response is nested in the 'value' column and I need to type test[[3]] to view each component of the 3rd respondent's answer. I would like each response from each respondent to appear in its own row in a new column but have no idea how. Thank you.

For example take the column:

Mode of travel

How can I separate the individual components of each response and populate a new column with each individual component?

0

There are 0 best solutions below