d_detrend: Detrend a delayed matrix

View source: R/delarr-verbs.R

d_detrendR Documentation

Detrend a delayed matrix

Description

Removes a polynomial trend of the specified degree along the chosen dimension.

Usage

d_detrend(x, dim = c("rows", "cols"), axis = NULL, degree = 1L)

Arguments

x

A delarr.

dim

Dimension along which to fit the trend.

axis

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

degree

Polynomial degree (default 1).

Value

A delarr with the detrend operation queued.

Examples

# Create matrix with linear trend in rows
mat <- matrix(1:12 + rep(1:4, each = 3), nrow = 3, ncol = 4)
darr <- delarr(mat)

# Remove linear trend along rows
detrended <- darr |> d_detrend(dim = "rows", degree = 1L) |> collect()
detrended

# Remove quadratic trend
quad_detrend <- darr |> d_detrend(dim = "rows", degree = 2L) |> collect()
quad_detrend

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