sortMat: Sort matrix

Description Usage Arguments Details Value Author(s) Examples

View source: R/functions.r

Description

Sorts the rows of a matrix by given columns.

Usage

1
sortMat(mat,cols)

Arguments

mat

matrix.

cols

sequence os columns to sort by.

Details

It is just a interface to the function order.

Value

Matrix.

Author(s)

Gabriel Coelho Goncalves de Abreu ([email protected])

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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

gRapHD documentation built on Feb. 9, 2018, 6:05 a.m.