reverse | R Documentation |
Reverse-score variables (change the keying/scoring direction).
reverse(x, ...)
reverse_scale(x, ...)
## S3 method for class 'numeric'
reverse(x, range = NULL, verbose = TRUE, ...)
## S3 method for class 'data.frame'
reverse(
x,
select = NULL,
exclude = NULL,
range = NULL,
append = FALSE,
ignore_case = FALSE,
regex = FALSE,
verbose = FALSE,
...
)
x |
A (grouped) data frame, numeric vector or factor. |
... |
Arguments passed to or from other methods. |
range |
Range of values that is used as reference for reversing the
scale. For numeric variables, can be |
verbose |
Toggle warnings. |
select |
Variables that will be included when performing the required tasks. Can be either
If |
exclude |
See |
append |
Logical or string. If |
ignore_case |
Logical, if |
regex |
Logical, if |
A reverse-scored object.
select
argumentFor most functions that have a select
argument (including this function),
the complete input data frame is returned, even when select
only selects
a range of variables. That is, the function is only applied to those variables
that have a match in select
, while all other variables remain unchanged.
In other words: for this function, select
will not omit any non-included
variables, so that the returned data frame will include all variables
from the input data frame.
Other transform utilities:
normalize()
,
ranktransform()
,
rescale()
,
standardize()
reverse(c(1, 2, 3, 4, 5))
reverse(c(-2, -1, 0, 2, 1))
# Specify the "theoretical" range of the input vector
reverse(c(1, 3, 4), range = c(0, 4))
# Factor variables
reverse(factor(c(1, 2, 3, 4, 5)))
reverse(factor(c(1, 2, 3, 4, 5)), range = 0:10)
# Data frames
head(reverse(iris))
head(reverse(iris, select = "Sepal.Length"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.