Note that this function tests whether the elements of abs(a)
are <= tol
.
So, you can set tol = 0
to discover if a
is EXACTLY the zero matrix.
iszero_byname(a, tol = 1e-06)
a | a matrix of list of matrices |
---|---|
tol | the allowable deviation from 0 for any element |
TRUE
iff this is the zero matrix within tol
.
#> [1] TRUE#> [1] FALSE#> [[1]] #> [1] TRUE #> #> [[2]] #> [1] FALSE #># And it works for data frames DF <- data.frame(A = I(list()), B = I(list())) DF[[1,"A"]] <- zero DF[[2,"A"]] <- nonzero DF[[1,"B"]] <- nonzero DF[[2,"B"]] <- zero iszero_byname(DF$A)#> [[1]] #> [1] TRUE #> #> [[2]] #> [1] FALSE #>iszero_byname(DF$B)#> [[1]] #> [1] FALSE #> #> [[2]] #> [1] TRUE #>#> [1] TRUE#> [1] FALSE