assert | R Documentation |
You can call this function with an arbitrary number of of
check*
functions, i.e. functions provided by the packages
checkmate
, NVIcheckmate
or your own functions which
return TRUE
on success and the error message as
character(1)
otherwise.
assert(..., combine = "or", .var.name = NULL, comment = NULL, add = NULL)
... |
[any] |
combine |
[ |
.var.name |
[ |
comment |
[ |
add |
[ |
The resulting assertion is successful, if combine
is
“or” (default) and at least one check evaluates to TRUE
or combine
is “and” and all checks evaluate to TRUE
.
Otherwise, assert
throws an informative error message.
Throws an error (or pushes the error message to an
AssertCollection
if add
is not NULL
)
if the checks fail and invisibly returns TRUE
otherwise.
x = 1:10
assert(checkmate::checkNull(x), checkmate::checkInteger(x, any.missing = FALSE))
collection <- checkmate::makeAssertCollection()
assert(checkmate::checkChoice(x, c("a", "b")), checkmate::checkDataFrame(x), add = collection)
collection$getMessages()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.