I have data like this
dataset = data.frame(id = c(1,2,1,4,5,6), class = c('a', 'a', 'b', 'a', 'b', 'b') )
I want to convert it into dummy vars but caret's dummy vars doesn't collapse id up it returns the same number of rows as the input. How do I group it so that id 1 has both a and b variables as 1?
dummies <- caret::dummyvars(id ~ . , data=dataset)
predict(dummies, newdata = dataset)