Useful for quickly checking to see if we have dropped rows or columns containing all zeros.

hasNonzeroRowsAndCols(x, .xname = getNameInParent(x))

Arguments

x

Object.

.xname

Name of object defined in x. Not intended to be used directly.

Value

TRUE on success; FALSE on failure, with cause set.

Details

This is a common check when handling RNA-seq data prior to generating a heatmap or applying a log transformation, for example.

Note

Updated 2019-10-04.

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 #> Cause: 'x' has 1 zero row at position 1.
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 #> Cause: 'x' has 1 zero column at position 1.