Learn R Programming

robustHD (version 0.3.0)

standardize: Data standardization

Description

Standardize data with given functions for computing center and scale.

Usage

standardize(x, centerFun = mean, scaleFun = sd)

  robStandardize(x, centerFun = median, scaleFun = mad,
    fallback = FALSE, eps = .Machine$double.eps, ...)

Arguments

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 mean).
scaleFun
a function to compute an estimate of the scale of a variable (defaults to sd).
fallback
a logical indicating whether standardization with mean and sd should be performed as a fallback mode for variables whose robust scale estimate is too
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.

Value

  • 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.

Details

robStandardize is a wrapper function for robust standardization, hence the default is to use median and mad.

See Also

scale, sweep

Examples

Run this code
## 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

Run the code above in your browser using DataLab