assert: Assert that certain conditions are true

View source: R/assert.R

assertR Documentation

Assert that certain conditions are true

Description

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

Usage

assert(..., msg = NULL)

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.

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.

Value

TRUE on success, error on failure.

Note

Updated 2021-10-08.

See Also

  • stopifnot().

  • assertthat::assert_that().

  • assertive.base::assert_engine().

  • checkmate::assert().

Examples

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

acidgenomics/r-goalie documentation built on Jan. 12, 2024, 4:15 a.m.