mutually_exclusive: Checks if the passed values are mutually exclusive.

View source: R/sets.R

mutually_exclusiveR Documentation

Checks if the passed values are mutually exclusive.

Description

Checks if the passed values are mutually exclusive, that is, if one of the passed values has a non-NULL value, all the others _must_ be NULL. If all options are NULL, by default this test passes. Setting allow_all_null = FALSE changes this behavior to failure. Setting it to FALSE basically ensures that exactly one of the values is not NULL.

This test is generally useful if two or more parameters in a routine are technically incompatible with each other, and you want the user to know the passed parameters in that combination don't make any sense.

Usage

mutually_exclusive(..., allow_all_null = TRUE)

Arguments

...

the various values

allow_all_null

If TRUE, then the test will succeed if all values are NULL. If FALSE, it will fail.

Examples

## Not run: 
# For assertion
assertthat::assert_that(
  qscheck::mutually_exclusive(parameter1, parameter2, parameter3)
)
# For check
if (
  qscheck::mutually_exclusive(parameter1, parameter2, parameter3)
) {}

## End(Not run)


AstraZeneca/qscheck documentation built on Nov. 1, 2023, 4:45 a.m.