Perform z-score scaling (center and scale to unit variance) on the active dimension. Requires rows or columns to be active.
Usage
# S3 method for class 'tidymatrix'
scale(x, center = TRUE, scale = TRUE)Examples
mat <- matrix(rnorm(20, mean = 10, sd = 5), nrow = 4, ncol = 5)
tm <- tidymatrix(mat)
# Scale rows (z-score per row)
tm_scaled <- tm |>
activate(rows) |>
scale()
# Scale columns
tm_scaled <- tm |>
activate(columns) |>
scale()
# Only center, don't scale
tm_centered <- tm |>
activate(rows) |>
scale(center = TRUE, scale = FALSE)