sortMat {gRapHD} | R Documentation |
Sort the rows of a matrix by given columns.
sortMat(mat,cols)
mat |
matrix. |
cols |
sequence os columns to sort by. |
It is just a interface to the function order
.
Matrix.
Gabriel Coelho Goncalves de Abreu (Gabriel.Abreu@agrsci.dk)
Rodrigo Labouriau (Rodrigo.Labouriau@agrsci.dk)
David Edwards (David.Edwards@agrsci.dk)
set.seed(1,kind="Mersenne-Twister") a <- matrix(c(sample(2,6,TRUE),sample(3,6,TRUE),sample(2,6,TRUE)),nrow=6) x <- sortMat(mat=a, cols=c(1:3)) # > a # [,1] [,2] [,3] # [1,] 1 3 2 # [2,] 1 2 1 # [3,] 2 2 2 # [4,] 2 1 1 # [5,] 1 1 2 # [6,] 2 1 2 # > x # [,1] [,2] [,3] # [1,] 1 1 2 # [2,] 1 2 1 # [3,] 1 3 2 # [4,] 2 1 1 # [5,] 2 1 2 # [6,] 2 2 2