Learn R Programming

gRapHD (version 0.2.5)

sortMat: Sort matrix

Description

Sorts the rows of a matrix by given columns.

Usage

sortMat(mat,cols)

Arguments

mat

matrix.

cols

sequence os columns to sort by.

Value

Matrix.

Details

It is just a interface to the function order.

Examples

Run this code
# NOT RUN {
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
# }

Run the code above in your browser using DataLab