View source: R/Data_handling.R
allNA | R Documentation |
allNA
returns a logical vector or array or list indicating whether
there are only NA
values in selected margins and therefore e.g.
statistics like max
or min
do not produce useful results.
allNA(x, margin)
x |
An array, including a matrix. |
margin |
A vector giving the subscripts which the function will be
applied over. E.g., for a matrix |
NA
for general information about NAs and
apply
for apply
description.
## Not run:
xx <- matrix(1:20, nrow = 4)
xx[2, ] <- NA
allNA(xx, 2) # All columns have at least one non-missing value
allNA(xx, 1) # Second row has all values missing
apply(xx, 1, max, na.rm = TRUE)
## returns c(17, -Inf, 19, 20) and a warning message
## Skip the allNA row in apply()
apply(xx[!allNA(xx, 1), ], 1, max, na.rm = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.