rankMulti: A multivariate adaptation of the rank() function

rankMultiR Documentation

A multivariate adaptation of the rank() function

Description

This function ranks values in a data frame or matrix by more than one field, with ties in one field broken by subsequent fields.

Usage

rankMulti(x, cols = 1:ncol(x), ...)

Arguments

x

Data frame or matrix.

cols

Names or indices of columns by which to rank, with first one gaining preference over the second, second over the third, etc.

...

Arguments to pass to rank. Note that if the ties.method argument is used the options 'first' or 'random' will rank by the first column uniquely such that there are no ties for subsequent columns to break.

Value

Numeric vector of ranks.

Examples


x <- data.frame(x1=c('a', 'b', 'b', 'c', 'a', 'a'), x2=c(11, 2, 1, NA, 10, 11))
rankMulti(x)
rankMulti(x, c('x2', 'x1'))


adamlilith/statisfactory documentation built on Jan. 3, 2024, 10:37 p.m.