Skip to contents

Does the requested input exist in the environment?

Usage

isExisting(x, envir = parent.frame(), inherits = FALSE)

isNonExisting(x, envir = parent.frame(), inherits = FALSE)

allAreExisting(x, envir = parent.frame(), inherits = FALSE)

allAreNonExisting(x, envir = parent.frame(), inherits = FALSE)

Arguments

x

character. Variable names to check in environment.

envir

environment. Environment.

inherits

logical(1). Should the enclosing frames of the environment be searched?

Value

TRUE on success; FALSE on failure, with cause set.

Functions

  • isExisting(): Vectorized.

  • isNonExisting(): Vectorized.

  • allAreExisting(): Scalar.

  • allAreNonExisting(): Scalar.

Note

exists() only supports character(1), so we are exporting isExisting() as a convenience function to check multiple variables in a single call.

Updated 2023-10-02.

See also

assertive.code::is_existing().

Examples

a <- 1L
b <- 2L

## TRUE ====
isExisting(c("a", "b"))
#> [1] TRUE TRUE
allAreNonExisting(c("x", "y"))
#> [1] TRUE

## FALSE ====
isExisting(c("x", "y"))
#> [1] FALSE FALSE