\Header{scale}{Scaling and Centering of Matrices}
\keyword{array}{scale}
\begin{Usage}
\begin{verbatim}
scale(x, center=TRUE, scale=TRUE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x}] a numeric matrix.
\item[\texttt{center}] either a logical value
or a numeric vector of length equal to the
number of columns of \texttt{x}.
\item[\texttt{scale}] either a logical value
or a numeric vector of length equal to the
number of columns of \texttt{x}.
\end{ldescription}
\end{Arguments}
\begin{Description}
The value of \texttt{center} determines how column
centering is performed.
If \texttt{center} is a numeric vector with length
equal to the number of columns of \texttt{x}, then
each column of \texttt{x} has the corresponding value
from \texttt{center} subtracted from it.
If \texttt{center} is \texttt{TRUE} then centering is
done by subtracting the column means of \texttt{x}
from their corresponding columns and if \texttt{center}
is \texttt{FALSE}, no centering is done.

The value of \texttt{scale} determines how column
scaling is performed (after centering).
If \texttt{scale} is a numeric vector with length
equal to the number of columns of \texttt{x}, then
each column of \texttt{x} is divided by the corresponding
value from \texttt{scale}.
If \texttt{scale} is \texttt{TRUE} then scaling is
done by dividing the (centered) columns of
\texttt{x} by their root-mean-square,
and if \texttt{scale} is \texttt{FALSE}, no scaling is done.

The root-mean-square for a column is obtained by computing
the square-root of the sum-of-squares of the non-missing
values in the column divided by the number of non-missing
values minus one.\end{Description}
\begin{Value}
The centered, scaled matrix.\end{Value}
\begin{SeeAlso}
\texttt{\Link{sweep}} which allows centering (and scaling) with
arbitrary statistics.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- matrix(1:10, nc=2)
(centered.x <- scale(x, scale=FALSE))
cov(centered.scaled.x <- scale(x))# all 1
\end{ExampleCode}
\end{Examples}

