consequential: Checks consequential presence of arguments.

View source: R/arguments.R

consequentialR Documentation

Checks consequential presence of arguments.

Description

Check that passes in either of the two cases: - if the first parameter (anchor) is not NULL, then the second parameter (dependent) must also not be NULL, or - if the first parameter (anchor) is NULL, then the second parameter (dependent) must also be NULL

This test is generally useful if one or more parameters in a routine are required if another parameter is passed, and are therefore consequential to its presence.

Usage

consequential(anchor, dependent)

Arguments

anchor

The parameter that decides if the other must be NULL or not.

dependent

The parameter that is dependent on anchor being NULL or not

Examples

## Not run: 
# For assertion. This passes if either is satisfied:
# If a is not NULL, then b must also be not NULL.
# If a is NULL, then b must also be NULL.
assertthat::assert_that(
  qscheck::consequential(a, b)
)
# For check
if (
  qscheck::consequential(a, b)
) {}

## End(Not run)


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