rescale {lessR} | R Documentation |
Rescale a Variable
Description
Rescale a variable to either z-scores with a mean of 0 and standard deviation of 1, normalized with a minimum of 0 and a maximum of 1, or to a variable computed like a z-score except use the median in place of the mean and the IQR in place of the standard deviation.
Usage
rescale(x, data=d, kind="z", digits_d=3)
Arguments
x |
Variable to rescale. |
data |
Data frame that contains |
kind |
Type of rescaling. |
digits_d |
Number of significant digits. |
Details
The default rescaling is standardization to z-scores, explicit with kind
set to "z"
, or just centering about the mean with "center"
. For the min-max normalization to a range from 0 to 1, set kind
to "0to1"
. For the robust equivalent of standardization, set kind
to "robust"
.
If x
is a vector in the global environment, then set data
to NULL
.
Value
The rescaled data.
Author(s)
David W. Gerbing (Portland State University; gerbing@pdx.edu)
See Also
Examples
# z-score for m01
d <- Read("Employee")
d[, .("Salary")]
x <- rescale(Salary)
x