Rev 7002 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{scale}\title{Scaling and Centering of Matrices}\usage{scale(x, center=TRUE, scale=TRUE)}\alias{scale}\arguments{\item{x}{a numeric matrix.}\item{center}{either a logical valueor a numeric vector of length equal to thenumber of columns of \code{x}.}\item{scale}{either a logical valueor a numeric vector of length equal to thenumber of columns of \code{x}.}}\details{Center and/or scale the columns of a numeric matrix.}\details{The value of \code{center} determines how columncentering is performed.If \code{center} is a numeric vector with lengthequal to the number of columns of \code{x}, theneach column of \code{x} has the corresponding valuefrom \code{center} subtracted from it.If \code{center} is \code{TRUE} then centering isdone by subtracting the column means of \code{x}from their corresponding columns and if \code{center}is \code{FALSE}, no centering is done.The value of \code{scale} determines how columnscaling is performed (after centering).If \code{scale} is a numeric vector with lengthequal to the number of columns of \code{x}, theneach column of \code{x} is divided by the correspondingvalue from \code{scale}.If \code{scale} is \code{TRUE} then scaling isdone by dividing the (centered) columns of\code{x} by their root-mean-square,and if \code{scale} is \code{FALSE}, no scaling is done.The root-mean-square for a column is obtained by computingthe square-root of the sum-of-squares of the non-missingvalues in the column divided by the number of non-missingvalues minus one.}\value{The centered, scaled matrix.}\seealso{\code{\link{sweep}} which allows centering (and scaling) witharbitrary statistics.}\examples{x <- matrix(1:10, nc=2)(centered.x <- scale(x, scale=FALSE))cov(centered.scaled.x <- scale(x))# all 1}\keyword{array}