Does the input contain non-zero rows and columns?
Source:R/check-scalar-hasNonzeroRowsAndCols.R
check-scalar-hasNonzeroRowsAndCols.Rd
Useful for quickly checking to see if we have dropped rows or columns containing all zeros.
Details
This is a common check when handling RNA-seq data prior to generating a heatmap or applying a log transformation, for example.
Examples
## TRUE ====
x <- matrix(data = seq_len(4L), nrow = 2L)
print(x)
#> [,1] [,2]
#> [1,] 1 3
#> [2,] 2 4
hasNonzeroRowsAndCols(x)
#> [1] TRUE
## FALSE ====
x <- matrix(data = rep(c(0L, 1L), times = 2L), nrow = 2L, byrow = FALSE)
print(x)
#> [,1] [,2]
#> [1,] 0 0
#> [2,] 1 1
hasNonzeroRowsAndCols(x)
#> [1] FALSE
x <- matrix(data = rep(c(0L, 1L), times = 2L), nrow = 2L, byrow = TRUE)
print(x)
#> [,1] [,2]
#> [1,] 0 1
#> [2,] 0 1
hasNonzeroRowsAndCols(x)
#> [1] FALSE