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 data.frame
ranktransform(
x,
sign = FALSE,
method = "average",
select = NULL,
exclude = NULL,
ignore_case = FALSE,
...
)
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.
Variables that will be included when performing the required tasks. Can be either
a variable specified as a literal variable name (e.g., column_name
),
a string with the variable name (e.g., "column_name"
), or a character
vector of variable names (e.g., c("col1", "col2", "col3")
),
a formula with variable names (e.g., ~column_1 + column_2
),
a vector of positive integers, giving the positions counting from the left
(e.g. 1
or c(1, 3, 5)
),
a vector of negative integers, giving the positions counting from the
right (e.g., -1
or -1:-3
),
or one of the following select-helpers: starts_with("")
, ends_with("")
,
contains("")
, a range using :
or regex("")
.
If NULL
, selects all columns.
See select
, however, column names matched by the pattern
from exclude
will be excluded instead of selected. If NULL
(the default),
excludes no columns.
Logical, if TRUE
and when one of the select-helpers or
a regular expression is used in select
, ignores lower/upper case in the
search pattern when matching against variable names.
A rank-transformed object.
Other transform utilities:
data_rescale()
,
data_reverse()
,
normalize()
,
standardize()
# NOT RUN {
ranktransform(c(0, 1, 5, -5, -2))
ranktransform(c(0, 1, 5, -5, -2), sign = TRUE)
head(ranktransform(trees))
# }
Run the code above in your browser using DataLab