Learn R Programming

assertive (version 0.2-6)

assert_all_are_existing: Does the variable exist?

Description

Checks to see if the input variables exist.

Usage

assert_all_are_existing(x, where = -1, envir = if (missing(frame))
  as.environment(where) else sys.frame(frame), frame, mode = "any",
  inherits = TRUE)

assert_any_are_existing(x, where = -1, envir = if (missing(frame))
  as.environment(where) else sys.frame(frame), frame, mode = "any",
  inherits = TRUE)

is_existing(x, where = -1, envir = if (missing(frame)) as.environment(where)
  else sys.frame(frame), frame, mode = "any", inherits = TRUE,
  .xname = get_name_in_parent(x))

Arguments

x
Input to check.
where
Passed to exists.
envir
Passed to exists.
frame
Passed to exists.
mode
Passed to exists.
inherits
Passed to exists.
.xname
Not intended to be used directly.

Value

  • is_existing is a vectorized wrapper to exists, providing more information on failure. The assert_* functions return nothing but throw an error if is_existing returns FALSE.

See Also

exists.

Examples

Run this code
e <- new.env()
e$x <- 1
e$y <- 2
assert_all_are_existing(c("x", "y"), envir = e)
#These examples should fail.
dont_stop(assert_all_are_existing(c("x", "z"), envir = e))

Run the code above in your browser using DataLab