
Last chance! 50% off unlimited learning
Sale ends in
Mean center a vector or numeric matrix.
m(x)
m
returns a mean centered version of x
. If x
is
a matrix, the matrix dimensions are preserved.
a numeric matrix or vector.
Mathijs Deen
This function resembles base::scale.default
, with the scale
argument set to FALSE
. This, together with the short function name, is
especially useful when you want to mean center variables in an analysis (e.g.,
using (g)lm
), but you dont want the long form scale(x, scale=FALSE)
to clutter up the rownames of the parameter estimates or the model anova.
vals <- matrix(rnorm(24, 15, 10), ncol = 2)
m(vals)
Run the code above in your browser using DataLab