| standardize | R Documentation |
Standardize data with given functions for computing center and scale.
standardize(x, centerFun = mean, scaleFun = sd)
robStandardize(
x,
centerFun = median,
scaleFun = mad,
fallback = FALSE,
eps = .Machine$double.eps,
...
)
x |
a numeric vector, matrix or data frame to be standardized. |
centerFun |
a function to compute an estimate of the center of a
variable (defaults to |
scaleFun |
a function to compute an estimate of the scale of a
variable (defaults to |
fallback |
a logical indicating whether standardization with
|
eps |
a small positive numeric value used to determine whether the robust scale estimate of a variable is too small (an effective zero). |
... |
currently ignored. |
robStandardize is a wrapper function for robust standardization,
hence the default is to use median and
mad.
An object of the same type as the original data x containing
the centered and scaled data. The center and scale estimates of the
original data are returned as attributes "center" and "scale",
respectively.
The implementation contains special cases for the typically used
combinations mean/sd and
median/mad in order to reduce
computation time.
Andreas Alfons
scale, sweep
## generate data
set.seed(1234) # for reproducibility
x <- rnorm(10) # standard normal
x[1] <- x[1] * 10 # introduce outlier
## standardize data
x
standardize(x) # mean and sd
robStandardize(x) # median and MAD
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.