Skip to content
Prev 215154 / 398500 Next

smart way to turn a vector into a matrix

anna wrote:
It was really the same answer as Phil.  Notice if you use a data.frame 
instead of a matrix, you don't have to recast to a 'matrix'-like form, 
and therefore the split call is a little simpler. Depending on what 
you're doing, it might or might not make sense.

initialDF <- 
data.frame(rbind(cbind(rep("A",3),seq(1,3)),cbind(rep("B",4),seq(1,4)),cbind(rep("C",3),seq(1,3))))

split(initialDF, initialDF[,1])