Learn R Programming

checkmate (version 1.0)

checkEnvironment: Check if an argument is an environment

Description

Check if an argument is an environment

Usage

checkEnvironment(x, contains = character(0L))

assertEnvironment(x, contains = character(0L), .var.name)

testEnvironment(x, contains = character(0L))

Arguments

x
[ANY] Object to check.
.var.name
[character(1)] Name for x. Defaults to a heuristic to determine the name using deparse and substitute.
contains
[character] Vector of object names expected in the environment. Defaults to character(0).

Value

  • Depending on the function prefix: If the check is successful, all functions return TRUE. If the check is not successful, assertEnvironment throws an error message, testEnvironment returns FALSE and checkEnvironment returns a string with the error message.

See Also

Other basetypes: assertArray, checkArray, testArray; assertAtomicVector, checkAtomicVector, testAtomicVector; assertAtomic, checkAtomic, testAtomic; assertCharacter, checkCharacter, testCharacter; assertComplex, checkComplex, testComplex; assertDataFrame, checkDataFrame, testDataFrame; assertFactor, checkFactor, testFactor; assertFunction, checkFunction, testFunction; assertIntegerish, checkIntegerish, testIntegerish; assertInteger, checkInteger, testInteger; assertList, checkList, testList; assertLogical, checkLogical, testLogical; assertMatrix, checkMatrix, testMatrix; assertNumeric, checkNumeric, testNumeric; assertVector, checkVector, testVector

Examples

Run this code
ee = as.environment(list(a = 1))
 testEnvironment(ee)
 testEnvironment(ee, contains = "a")

Run the code above in your browser using DataLab