.BG
.VE $Header: /usr3/s/current/s/.help/RCS/scale,v 1.2 83/12/30 19:34:09 rab Exp $
.FN scale
.TL
scale: Scale Columns of a Matrix
.CS
scale(x, center, scale)
.PP
.AG x
matrix to be scaled.  Missing values (NAs) are allowed.
.AG center
control over the value subtracted from each column.  If TRUE
(the default), the mean of (the non-missing data in)
each column is subtracted from each column.  If
given as a vector of length `ncol(x)', this vector is used;
i.e., `center[j]' is subtracted from column `j'.  If FALSE,
no centering is done.
.AG scale
control over the value divided into each column to scale it.
If TRUE (the default) each column (after centering) is divided by
the square root of sum-of-squares over `n\-1',
where `n' is the number of
of non-missing values.
If given as a vector of length `ncol(x)', column
`j' is divided by `scale[j]'.  If FALSE, no scaling is done.
.RT
matrix like `x' with optional centering and scaling.
.PP
The default values of `center' and `scale'
produce columns with mean 0 and standard deviation 1.
.EX
scale(x) #scale to correlation (0 mean, 1 std dev)
scale(x, center=apply(x,2,"median"),
  scale=FALSE) #remove column medians, do not scale
  # see also `sweep'
.KW array*
.KW matrix
.KW scaling
.KW algebra
.WR
