0 and sample standard
deviation
1.
scale(x, center=T, scale=T)
NAs) are allowed.
TRUE,
the mean of (the non-missing data in)
each column is subtracted from the 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.
TRUE each column (after centering) is divided by
the square root of sum-of-squares (after centering) over
n-1,
where
n is the number 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.
x with optional centering and scaling.
scale takes as an argument
x (matrix) and returns a similar matrix whose
columns take elements corresponding to the
center (mean), and
scale
(standard deviation). If
center and
scale are not specified, the
default values will be 0 and 1, respectively.
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