Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

checkTRUE

Check if an argument is TRUE


Description

Simply checks if an argument is TRUE.

Usage

checkTRUE(x, na.ok = FALSE)

check_true(x, na.ok = FALSE)

assertTRUE(x, na.ok = FALSE, .var.name = vname(x), add = NULL)

assert_true(x, na.ok = FALSE, .var.name = vname(x), add = NULL)

testTRUE(x, na.ok = FALSE)

test_true(x, na.ok = FALSE)

Arguments

x

[any]
Object to check.

na.ok

[logical(1)]
Are missing values allowed? Default is FALSE.

.var.name

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

add

[AssertCollection]
Collection to store assertion messages. See AssertCollection.

Value

Depending on the function prefix: If the check is successful, the functions assertTRUE./assert_true. return x invisibly, whereas checkTRUE./check_true. and testTRUE./test_true. return TRUE. If the check is not successful, assertTRUE./assert_true. throws an error message, testTRUE./test_true. returns FALSE, and checkTRUE. returns a string with the error message. The function expect_true. always returns an expectation.

Examples

testTRUE(TRUE)
testTRUE(FALSE)

checkmate

Fast and Versatile Argument Checks

v2.0.0
BSD_3_clause + file LICENSE
Authors
Michel Lang [cre, aut] (<https://orcid.org/0000-0001-9754-0393>), Bernd Bischl [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.