invalid: Test if a value is missing, empty, contains only NA or NULL...

View source: R/invalid.R

invalidR Documentation

Test if a value is missing, empty, contains only NA or NULL values, or is a try-error.

Description

Test if a value is missing, empty, contains only NA or NULL values, or is a try-error.

Usage

invalid(x)

Arguments

x

value to be tested

Value

Logical value.

Author(s)

Gregory R. Warnes greg@warnes.net

See Also

missing, is.na, is.null

Examples



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)

gtools documentation built on Nov. 20, 2023, 5:07 p.m.