sortmat: Sort a square matrix This uses an iterative algorithm that...

View source: R/matrix.R

sortmatR Documentation

Sort a square matrix This uses an iterative algorithm that swaps the rows and columns of a matrix to ensure the highest values are either in the middle or the bottom-right.

Description

Sort a square matrix This uses an iterative algorithm that swaps the rows and columns of a matrix to ensure the highest values are either in the middle or the bottom-right.

Usage

sortmat(mat, sorttype = c("diag", "center", "bottomright"))

Arguments

mat

Square numeric matrix to be sorted.

sorttype

Where the highest values should appear - "diag", "center", or "bottomright".

Value

A sorted square matrix.

Author(s)

Sercan Kahveci

Examples


mat<-matrix(rnorm(144),ncol=12,nrow=12)
mat<-mat+t(mat)

newmat1<-sortmat(mat,"bottomright")

newmat2<-sortmat(mat,"diag")

newmat3<-sortmat(mat,"center")


Spiritspeak/skMisc documentation built on April 12, 2025, 5:40 a.m.