sortrank.Rd
A utility that returns a list with the components equivalent to sort(x), order(x), rank(x, ties.method = "first").
sortrank(x)
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")
.
A list with components
the sorted input vector x
the permutation = order(x) which rearranges x into ascending order
the ranks of x
This function was benchmarked faster than the combined calls to sort
and rank
.
See sort
.
sortrank(rnorm(5))
#> $x
#> [1] -0.5785381 -0.4833321 0.6799946 0.8886331 1.6365181
#>
#> $ix
#> [1] 5 1 3 4 2
#>
#> $r
#> [1] 2 5 3 4 1
#>