zero_col: Check for empty matrix columns (or rows)

View source: R/zero_col.R

zero_colR Documentation

Check for empty matrix columns (or rows)

Description

More generally, checks that both row/col sums and sums of absolute values equal a target. For value = 0, this means all entries are zero. single_col() is a wrapper with value = 1, often used to check for dummy columns/rows with exactly one element that is 1.

Usage

zero_col(x, rows = FALSE, value = 0)

single_col(..., value = 1)

Arguments

x

Numeric matrix. Sparse matrices from the Matrix package are also supported.

rows

Logical; if TRUE check rows, else columns.

value

Numeric target (default 0).

...

Passed to zero_col().

Details

Memory usage is reduced by applying abs() checks only to rows/columns whose total sum is already the target.

Value

Logical vector.

Examples

m <- matrix(c(
  0,  0, 0, 0, 
  1, -1, 0, 0,
  0,  0, 1, 0
), nrow = 3, byrow = TRUE)

zero_col(m)
zero_col(m, rows = TRUE)
single_col(m)
single_col(m, rows = TRUE)


SSBtools documentation built on Nov. 5, 2025, 6:51 p.m.

Related to zero_col in SSBtools...