I have to split a vector into n chunks of equal size in R. I couldn\'t find any base function to do that. Also Google didn\'t get me anywhere. Here is what I came up with so
split(x,matrix(1:n,n,length(x))[1:length(x)])
perhaps this is more clear, but the same idea: split(x,rep(1:n, ceiling(length(x)/n),length.out = length(x)))
split(x,rep(1:n, ceiling(length(x)/n),length.out = length(x)))
if you want it ordered,throw a sort around it