sortMat {gRapHD}R Documentation

Sort matrix

Description

Sort the rows of a matrix by given columns.

Usage

  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 (Gabriel.Abreu@agrsci.dk)
Rodrigo Labouriau (Rodrigo.Labouriau@agrsci.dk)
David Edwards (David.Edwards@agrsci.dk)

Examples

  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

[Package gRapHD version 0.1.0 Index]