round_rank {comperank}R Documentation

Rank vector after rounding

Description

Function for ranking vector after rounding.

Usage

round_rank(x, type = "desc", na.last = TRUE, ties = c("average", "first",
  "last", "random", "max", "min"), round_digits = 7)

Arguments

x

A numeric, complex, character or logical vector.

type

Type of ranking: "desc" or "asc" (see Details).

na.last

For controlling the treatment of NAs. If TRUE, missing values in the data are put last; if FALSE, they are put first; if NA, they are removed; if "keep" they are kept with rank NA.

ties

A character string specifying how ties are treated (see Details). Can be abbreviated.

round_digits

Value of digits for round().

Details

This is basically a wrapper around rank() in which x is pre-modified by rounding to specific number of digits round_digits.

type can have two values: "desc" for ranking in descending order (rank 1 is given to the biggest value in x) and "asc" (rank 1 is given to the smallest value in x). Any other value will cause error.

Value

A numeric vector of the same length as x with names copied from x (unless na.last = NA, when missing values are removed). The vector is of integer type unless x is a long vector or ties = "average" when it is of double type (whether or not there are any ties).

Examples

round_rank(10:1, type = "desc")
round_rank(10:1, type = "asc")

set.seed(334)
x <- 10^(-10) * runif(10)
round_rank(x)


[Package comperank version 0.1.1 Index]