Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sort_mat

Sorting of the columns-rows of a matrix


Description

Fast sorting of the columns-rows of a matrix.

Usage

colSort(x, descending = FALSE, stable = FALSE,parallel=FALSE)
rowSort(x, descending = FALSE, stable = FALSE,parallel=FALSE)
sort_mat(x,by.row=FALSE,descending=FALSE,stable=FALSE,parallel=FALSE)

Arguments

x

A numerical matrix with data.

descending

If you want the sorting in descending order, set this to TRUE.

stable

If you the stable version, so that the results are the same as R's (in the case of ties) set this to TRUE. If this is TRUE, the algorithm is a bit slower.

parallel

Do you want to do it in parallel in C++? TRUE or FALSE. Works with every other argument.

by.row

TRUE or FALSE for applying sort in rows or column.

Value

The matrix with its columns-rows (or rows) independently sorted.

Author(s)

Manos Papadakis

R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.

See Also

Examples

x <- matrix( rnorm(100 * 500), ncol = 500 )
system.time( s1 <- colSort(x) )
system.time( s2 <- apply(x, 2, sort)  )
all.equal(as.vector(s1), as.vector(s2))

x<-NULL

Rfast

A Collection of Efficient and Extremely Fast R Functions

v2.0.1
GPL (>= 2.0)
Authors
Manos Papadakis, Michail Tsagris, Marios Dimitriadis, Stefanos Fafalios, Ioannis Tsamardinos, Matteo Fasiolo, Giorgos Borboudakis, John Burkardt, Changliang Zou, Kleanthi Lakiotaki and Christina Chatzipantsiou.
Initial release
2020-09-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.