Transform numeric values with the integers of their rank (i.e., 1st smallest, 2nd smallest, 3rd smallest, etc.). Setting the sign argument to TRUE will give you signed ranks, where the ranking is done according to absolute size but where the sign is preserved (i.e., 2, 1, -3, 4).

ranktransform(x, ...)

# S3 method for numeric
ranktransform(x, sign = FALSE, method = "average", verbose = TRUE, ...)

# S3 method for grouped_df
ranktransform(
x,
select = NULL,
exclude = NULL,
sign = FALSE,
method = "average",
...
)

# S3 method for data.frame
ranktransform(
x,
select = NULL,
exclude = NULL,
sign = FALSE,
method = "average",
...
)

## Arguments

x Object. Arguments passed to or from other methods. Logical, if TRUE, return signed ranks. Treatment of ties. Can be one of "average" (default), "first", "last", "random", "max" or "min". See rank() for details. Toggle warnings and messages on or off. Character vector of column names. If NULL (the default), all variables will be selected. Character vector of column names to be excluded from selection.

## Value

A rank-transformed object.

Other transform utilities: change_scale(), normalize(), standardize()

## Examples

ranktransform(c(0, 1, 5, -5, -2))
#> [1] 3 4 5 1 2
ranktransform(c(0, 1, 5, -5, -2), sign = TRUE)
#> Warning: Zeros detected. These cannot be sign-rank transformed.
#> [1]   NA  1.0  3.5 -3.5 -2.0