sortrank: Sort, order and rank a vector

View source: R/util.R

sortrankR Documentation

Sort, order and rank a vector

Description

A utility that returns a list with the components equivalent to sort(x), order(x), rank(x, ties.method = "first").

Usage

sortrank(x)

Arguments

x

vector compatible with sort(x)

Details

This utility exists to save a little time on large vectors when two or all three of the sort(), order(), rank() results are required. In case of ties, the ranks component matches rank(x, ties.method = "first").

Value

A list with components

x

the sorted input vector x

ix

the permutation = order(x) which rearranges x into ascending order

r

the ranks of x

Note

This function was benchmarked faster than the combined calls to sort and rank.

Author(s)

Maria L. Rizzo mrizzo@bgsu.edu

References

See sort.

Examples

sortrank(rnorm(5))

energy documentation built on Sept. 11, 2024, 7:57 p.m.