Skip to contents

Center the active dimension by subtracting the mean. Requires rows or columns to be active.

Usage

# S3 method for class 'tidymatrix'
center(x, ...)

Arguments

x

A tidymatrix object with rows or columns active

...

Not used

Value

A tidymatrix object with centered matrix

Examples

mat <- matrix(rnorm(20, mean = 10), nrow = 4, ncol = 5)
tm <- tidymatrix(mat)

# Center rows (mean of each row = 0)
tm_centered <- tm |>
  activate(rows) |>
  center()

# Center columns (mean of each column = 0)
tm_centered <- tm |>
  activate(columns) |>
  center()