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

Sean Davis sdavis2 at mail.nih.gov
Wed Dec 8 19:15:26 CET 2004


There is probably a neater solution, but....

x <- matrix(1:1000,nrow=500)
y <- runif(500)
z <- x[order(y),]

On Dec 8, 2004, at 8:23 AM, Andreas wrote:

> 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
>
> ______________________________________________
> R-help at 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




More information about the R-help mailing list