Description Usage Arguments Value Author(s) Examples
Sorts a matrix in respect to one or more specified columns by preserving its row context. If more than one columns is given the function uses the columns in the specified order for sorting.
1 |
mat |
matrix to be sorted |
sort |
column indices |
decreasing |
logical, if TRUE the column is ordered decreasingly |
Returns the sorted matrix.
Franziska Hoffgaard
1 2 3 4 5 6 7 8 9 | mat<-matrix(data = as.integer(runif(16, 1, 20)), nrow = 4)
#Sort the matrix in respect to the second column of mat
m<-mat.sort(mat, 2)
#Sorting mat according to more than one column
mat<-matrix(data = c(rep(3, 3), as.integer(runif(13, 1, 20))), nrow = 4)
m1<-mat.sort(mat, c(1, 2))
m2<-mat.sort(mat, c(2, 1))
|
Loading required package: snow
Loading required package: matrixcalc
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.