Consider na=43; nb=5; x=1:na ns=rep(na %/% nb, nb) + (1:nb <= na %% nb) split(x, rep(1:nb, ns))
Heikki Kaskelma On Fri, 2 Feb 2007, jim holtman <[EMAIL PROTECTED]> wrote: >This might do what you want: > > # test data > x <- 1:43 > nb <- 5 # number of subsets > # create vector of lengths of subsets > ns <- rep(length(x) %/% nb, nb) > # see if we have to adjust counts of initial subsets > if ((.offset <- length(x) %% nb) != 0) ns[1:.offset] = ns[1:.offset] + 1 > # create the subsets > split(x, rep(1:nb,ns)) ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.