Description Usage Arguments Value Author(s) Examples
Enables the centering and scaling of the columns of a matrix, to have zero mean and unit variance.
1 |
x |
Matrix to be centred and/or scaled. |
centre |
Should the columns of |
stand |
Should the columns of |
Returns matrix x
with the columns centred and/or scaled.
Theo Pepler
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (x, centre = FALSE, stand = TRUE)
{
if (centre) {
for (i in 1:ncol(x)) {
x[, i] <- x[, i] - mean(x[, i])
}
}
if (stand) {
for (i in 1:ncol(x)) {
x[, i] <- x[, i]/sd(x[, i])
}
}
return(x)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.