Scale a delayed matrix along rows or columns
Usage
d_scale(x, dim = c("rows", "cols"), center = TRUE, scale = TRUE, na.rm = FALSE)Examples
mat <- matrix(c(1, 2, 3, 10, 20, 30), nrow = 2, ncol = 3)
darr <- delarr(mat)
# Scale rows (center and divide by SD)
scaled <- darr |> d_scale(dim = "rows") |> collect()
scaled
#> [,1] [,2] [,3]
#> [1,] -0.6704784 -0.4789131 1.149392
#> [2,] -0.8320503 -0.2773501 1.109400
# Scale without centering
scaled_only <- darr |> d_scale(dim = "rows", center = FALSE) |> collect()
scaled_only
#> [,1] [,2] [,3]
#> [1,] 0.09578263 0.2873479 1.915653
#> [2,] 0.13867505 0.6933752 2.080126