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

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



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.


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


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


TRUE on success, error on failure.

See also


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