After centering, rowsums sum to zero. Particularly useful when working with categorical data in log-space.

center(x)

Arguments

x

vector or matrix

Value

matrix with centered rows

Examples

x <- matrix(rnorm(100), 10, 10) y <- center(x) rowSums(y)
#> [1] 7.632783e-17 1.665335e-16 5.551115e-16 -1.665335e-16 -4.440892e-16 #> [6] 1.665335e-16 -2.498002e-16 5.551115e-17 1.387779e-16 2.220446e-16