[R] randomly permuting rows or col's of a matrix
B.Rowlingson at lancaster.ac.uk
Tue Nov 25 11:38:03 CET 2003
Pascal A. Niklaus wrote:
> Is there an shortcut (compared to "manually" swap row vectors) for the
> random permutation of rows of a matrix?
> "sample" does not act on the element row vectors as a whole.
True, but sample(nrow(foo)) gives you a permutation of 1:nrow(foo)
that you can subscript with:
More information about the R-help