Learn R Programming

ribiosUtils (version 1.7.7)

sortByDimnames: Sort matrix by dim names

Description

Rearrange rows and columns of a matrix by dim names

Usage

sortByDimnames(x, row.decreasing = FALSE, col.decreasing = FALSE)

Value

Resorted matrix or data frame

Arguments

x

A matrix or data.frame

row.decreasing

Logical, whether rows should be sorted decreasingly

col.decreasing

Logical, whether columns should be sorted decreasingly

Author

Jitao David Zhang <jitao_david.zhang@roche.com>

Examples

Run this code

testMat <- matrix(1:16, nrow=4, dimnames=list(c("B", "D", "A", "C"), c("t", "f", "a", "g")))
sortByDimnames(testMat)
sortByDimnames(testMat, row.decreasing=TRUE, col.decreasing=FALSE)

Run the code above in your browser using DataLab