[R] randomize the order of rows in a matrix or table

Liaw, Andy andy_liaw at merck.com
Wed Dec 8 19:09:37 CET 2004

mydata <- mydata[sample(nrow(mydata)), ]


> From: Andreas
> Hello,
> is there any function to randomize the order of rows in 
> matrix. My dataset
> for suport vector mashines is in the order first the samples 
> of class1 and
> then the samples for class2. For the training of the svm I 
> need this dataset
> randomized in its order.
> regards Andreas

More information about the R-help mailing list