I am trying to take a dataframe like this
name response
1 Phil Exam
2 Terry Test
3 Simmon Exam
4 Brad Quiz
And turn it into this
name response Exam Test Quiz
1 Phil Exam Exam
2 Terry Test Test
3 Simmon Exam Exam
4 Brad Quiz Quiz
I tried to use a for loop, extracting each row. Then I would check to see if the column already existed and if it did not it would create a new column. I couldnt get this close to working and am unsure how to do this.
cbind(dat, model.matrix(~ response + 0, data=dat))