Skip to contents

It centers a numeric matrix with dimension N x N by row (rows=TRUE) or column (rows=FALSE).

Usage

centerX(X, rows = TRUE)

Arguments

X

Numeric matrix or data.frame of any size.

rows

If TRUE, the operation is done by row; otherwise, it is done by column. (Defaults: TRUE).

Value

Centered X (class "matrix").

Examples

dat <- matrix(rnorm(25),ncol=5,nrow=5)
centerX(dat)
#>             [,1]        [,2]         [,3]        [,4]       [,5]
#> [1,] -0.06330487 -0.79913007  0.342829129 -0.02348244  0.5430883
#> [2,] -0.12841655  0.06434823 -0.648148933  0.90423167 -0.1920144
#> [3,]  0.44837762  0.25795955  0.004895096 -1.06952003  0.3582878
#> [4,]  1.69124700 -0.58147244 -0.098478548 -1.12075952  0.1094635
#> [5,]  1.77331826 -0.64568901 -0.717794798  0.52078744 -0.9306219