Learn R Programming

MDMA (version 1.1.0)

m: Mean center

Description

Mean center a vector or numeric matrix.

[Stable]

Usage

m(x)

Value

m returns a mean centered version of x. If x is a matrix, the matrix dimensions are preserved.

Arguments

x

a numeric matrix or vector.

Author

Mathijs Deen

Details

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.

Examples

Run this code
vals <- matrix(rnorm(24, 15, 10), ncol = 2)
m(vals)

Run the code above in your browser using DataLab