invalid | R Documentation |
Test if a value is missing, empty, contains only NA or NULL values, or is a try-error.
invalid(x)
x |
value to be tested |
Logical value.
Gregory R. Warnes greg@warnes.net
missing
, is.na
,
is.null
invalid(NA)
invalid()
invalid(c(NA, NA, NULL, NA))
invalid(list(a = 1, b = NULL))
x <- try(log("A"))
invalid(x)
# example use in a function
myplot <- function(x, y) {
if (invalid(y)) {
y <- x
x <- 1:length(y)
}
plot(x, y)
}
myplot(1:10)
myplot(1:10, NA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.