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. Thanks Pascal
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: foo[sample(nrow(foo)),] or foo[,sample(ncol(foo))] Baz