0

I have a df of about 50 likert-type questions (n=4,800). I want to create a binary for each response option in a question for each question for studying direction and strength. I have no idea how to do this in R, so all I can do is describe the input and output.

Say I have a question (Q1) with five possible responses from 1 to 5. I want to create 5 binaries (0,1) using the response possibilities included in the variable name, initialized to 0:

Q1_1 = 0; Q1_2 = 0; Q1_3 = 0; Q1_4 = 0; Q1_5 = 0

Say person one gives an answer of 4 so I change Q1_4 to 1, leaving the others a 0:

Q1_1 = 0; Q1_2 = 0; Q1_3 = 0; Q1_4 = 1; Q1_5 = 0

The number of answer options per question ranges from 2 to 6 (some questions have 2 options, others have as many as 6. Is this even possible in R? (I can do it (painfully) in Excel.)

  • The two dupe-links have several methods for getting the binary variables you request. If they do not meet your needs, please provide sample data, code that you've attempted, and why the actual output is incorrect. Thanks! – r2evans Dec 13 '21 at 15:42

0 Answers0