centredAndScaled | R Documentation |
centredAndScaled
centres (subtracts the mean) and scales (divides by
the standard deviation) each column of a numeric vector or matrix.
centredAndScaled(nsloc = NULL)
nsloc |
data.frame. If |
If nsloc
has only one column, the function computes the mean and
standard deviation of the entire vector. If nsloc
has multiple
columns, each column is centred and scaled independently.
A numeric vector or matrix of the same dimensions as the input,
with each column centred to mean zero and scaled to unit variance. If
nsloc
is NULL
, returns NULL
.
# Centre and scale a simple vector
centredAndScaled(data.frame(1:10))
# Centre and scale each column of a matrix
mat <- as.data.frame(matrix(stats::rnorm(30), nrow = 10, ncol = 3))
centredAndScaled(mat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.