[R] Does split() preserve order?

Alistair Gee alistair.gee at gmail.com
Thu Aug 27 01:41:28 CEST 2009


If x is a vector (or data frame) that is in a particular order, and I
call split(x, f) to partition x, will the elements of each partition
remain in order?

That is, is the following assertion always TRUE?

for(i in split(x, f)) {
  stopifnot(!is.unsorted(i))
}

I suspect that this is the case, but the help page does not discuss
preservation of order in the result of split().




More information about the R-help mailing list