d_scale: Scale a delayed matrix along rows or columns

View source: R/delarr-verbs.R

d_scaleR Documentation

Scale a delayed matrix along rows or columns

Description

Scale a delayed matrix along rows or columns

Usage

d_scale(
  x,
  dim = c("rows", "cols"),
  axis = NULL,
  center = TRUE,
  scale = TRUE,
  na.rm = FALSE
)

Arguments

x

A delarr.

dim

Dimension to scale.

axis

Integer axis for N-d arrays (alternative to dim).

center

Logical; subtract the mean before scaling.

scale

Logical; divide by the standard deviation.

na.rm

Logical; remove missing values when computing statistics.

Value

A delarr with a deferred scaling operation.

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

# Scale without centering
scaled_only <- darr |> d_scale(dim = "rows", center = FALSE) |> collect()
scaled_only

delarr documentation built on July 1, 2026, 1:06 a.m.