Rank: Column and row-wise ranks

View source: R/Rank.R

Column and row-wise ranksR Documentation

Column and row-wise ranks

Description

Column and row-wise ranks.

Usage

colRanks(x,method = "average",descending = FALSE,
     stable = FALSE, parallel = FALSE, cores = 0)
rowRanks(x,method = "average",descending = FALSE,
     stable = FALSE, parallel = FALSE, cores = 0)
Rank(x,method = "average",descending = FALSE,stable = FALSE, parallel = FALSE)

Arguments

x

A mumerical matrix or data.frame with the data.

parallel

A boolean value for parallel version.

method

a character string for choosing method. Must be one of:

  • average : a permutation with theri mean values at each index set of ties

  • min : a permutation with minimum values at each index set of ties

  • max : a permutation with maximum values at each index set of ties

  • first : a permutation with increasing values at each index set of ties

  • random : a permutation with random values at each index set of ties

descending

A boolean value (TRUE/FALSE) for sorting the vector in descending order. By default sorts the vector in ascending.

stable

A boolean value (TRUE/FALSE) for choosing a stable sort algorithm. Stable means that discriminates on the same elements. Only for the method "first".

cores

Number of cores to use for parallelism. Valid only when argument parallel is set to TRUE. Default value is 0 and it means the maximum supported cores.

Details

For each column or row of a matrix the ranks are calculated and they are returned.

Value

A matrix with the column or row-wise ranks.

Author(s)

Manos Papadakis

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

See Also

Rank, correls

Examples

x <- matrnorm(100, 10)
a1 <- colRanks(x)
a2 <- apply(x, 2, rank)
b1 <- rowRanks(x)
b2 <- apply(x, 1, rank)

a1 <- Rank(x[,1])
a1 <- rank(x[,1])

x<-a1<-a2<-b1<-b2<-NULL

Rfast documentation built on Nov. 9, 2023, 5:06 p.m.