check_non_null: Check if two or more arguments are NULL or NA

View source: R/check_non_null.R

check_non_nullR Documentation

Check if two or more arguments are NULL or NA

Description

Check whether two or more arguments that may replace each other are NULL or NA.

Usage

check_non_null(x)

assert_non_null(x, .var.name = checkmate::vname(x), comment = NULL, add = NULL)

Arguments

x

[any]
List with objects to check.

.var.name

[character(1)]
Name of the checked object to print in error messages. Defaults to the heuristic implemented in vname.

comment

[character(1)]
Extra information to be appended to the standard error message in assertions.

add

[AssertCollection]
Collection to store assertions. See AssertCollection.

Details

In some functions, one argument may replace another. The check is used to ensure that at least on of the arguments have a value. Specific checks for each argument should be used in addition.

Value

Depending on the function prefix:
If the check is successful, the function assert_non_null return x invisibly, whereas check_non_null return TRUE.
If the check is not successful, assert_non_null throws an error message and check_non_null returns a string with the error message.

Examples

data <- NULL
nrows_in_data <- 56
check_non_null(x = list(data, nrows_in_data))

PetterHopp/NVIcheckmate documentation built on Dec. 15, 2024, 12:49 a.m.