assert() is a drop-in replacement for stopifnot() supporting more informative error messages.

assert(..., msg = NULL, traceback = getOption("goalie.traceback",
  FALSE))

Arguments

...

Any number of R expressions that return logical(1), each of which should evaluate to TRUE. Rather than combining expressions with &&, separate them by commas so that better error messages can be generated.

msg

NULL or character(1). Custom message to return on the event of any check failure.

traceback

logical(1). Include traceback in error message. See traceback() for details. rlang::entrace() also works nicely and can be set in .Rprofile.

Value

TRUE on success, error on failure.

See also

Examples

assert( is.atomic("example"), is.character("example") )