inspect_true_or_false: Validate non-missing logical values

Description Usage Arguments Details Value See Also Examples

View source: R/inspect_.R

Description

inspect_true_or_false checks if an object is a non-missing logical vector of length 1. This can be useful to validate inputs in user-defined functions.

Usage

1

Arguments

x

An arbitrary object.

Details

inspect_true_or_false conducts a series of tests to check if x is a non-missing logical vector of length 1. Namely, inspect_true_or_false checks if:

Value

inspect_true_or_false does not return any output. There are two possible scenarios:

See Also

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Calls that pass silently:
x <- TRUE
y <- FALSE
inspect_true_or_false(x)
inspect_true_or_false(y)

# Calls that throw informative error messages:
mylist <- list(NULL, NA, NaN, 1, 0, "TRUE")
try(inspect_true_or_false(mylist[[1]]))
try(inspect_true_or_false(mylist[[2]]))
try(inspect_true_or_false(mylist[[3]]))
try(inspect_true_or_false(mylist[[4]]))
try(inspect_true_or_false(mylist[[5]]))
try(inspect_true_or_false(mylist[[6]]))

inspector documentation built on June 18, 2021, 1:06 a.m.