assert()
is a drop-in replacement for stopifnot()
that supports more
informative error messages.
Arguments
- ...
Any number of R expressions that return
logical(1)
, each of which should evaluate toTRUE
. Rather than combining expressions with&&
, separate them by commas so that better error messages can be generated.- msg
NULL
orcharacter(1)
. Custom message to return.
Details
If any of the expressions defined in ...
are TRUE
, stop()
is called,
producing an error message indicating the first expression which was not
TRUE
.
Examples
assert(
is.atomic("example"),
is.character("example")
)