This function checks a numeric matrix for rows or columns with zero variance. It reports how many and which ones are affected, using either their names (if present) or indices.

check_zero_variance(mat)

Arguments

mat

A numeric matrix.

Value

Boolean checking if any zero-variance rows or columns found.

Details

Zero variance means all values in a row or column are identical (after removing NAs).

Examples

m <- matrix(c(1, 1, 1,
              2, 3, 4,
              5, 6, 7),
            nrow = 3, byrow = TRUE)
rownames(m) <- c("rowA", "rowB", "rowC")
colnames(m) <- c("colX", "colY", "colZ")
check_zero_variance(m)
#> Warning: Zero variance in 1 rows: rowA
#> [1]  TRUE FALSE