scale {base}R Documentation

Scaling and Centering of Matrices

Usage

scale(x, center=TRUE, scale=TRUE)

Arguments

x a numeric matrix.
center either a logical value or a numeric vector of length equal to the number of columns of x.
scale either a logical value or a numeric vector of length equal to the number of columns of x.

Details

Center and/or scale the columns of a numeric matrix.

Value

The centered, scaled matrix.

See Also

sweep which allows centering (and scaling) with arbitrary statistics.

Examples

x <- matrix(1:10, nc=2)
(centered.x <- scale(x, scale=FALSE))
cov(centered.scaled.x <- scale(x))# all 1


[Package Contents]