Split a vector into three vectors of unequal length in R
a questions from a relative n00b: I'd like to split a vector into three
vectors of different lengths, with the values assigned to each vector at
random. For example, I'd like to split the vector of length 12 below into
vectors of length 2,3, and 7
I can get three equal sized vectors using this:
test<-1:12 split(test,sample(1:3))
Any suggestions on how to split test into vectors of 2,3, and 7 instead of
three vectors of length 4?
No comments:
Post a Comment