assert {checkmate}R Documentation

Combine multiple checks into one assertion

Description

You can call this function with an arbitrary number of of check* functions. The resulting assertion is successful, if combine is “or” (default) and at least one check evaluates to TRUE or combine is “and” and all checks evaluate to TRUE. Otherwise, assert throws an informative error message.

Usage

assert(..., combine = "or", .var.name)

Arguments

...

[any]
List of calls to check functions.

combine

[character(1)]
“or” or “and” to combine the check functions with an OR or AND, respectively.

.var.name

[character(1)]
Name of object to check. Defaults to a heuristic to determine the name of the first argument of the first call.

Value

Throws an error if all checks fails and invisibly returns TRUE otherwise.

Examples

x = 1:10
assert(checkNull(x), checkInteger(x, any.missing = FALSE))
## Not run: 
x = 1
assert(checkChoice(x, c("a", "b")), checkDataFrame(x))

## End(Not run)

[Package checkmate version 1.6.0 Index]