checkmate (version 1.7.2)

qassertr: Quick recursive arguments checks on lists and data frames

Description

These functions are the tuned counterparts of qtest, qassert and qexpect tailored for recursive checks of list elements or data frame columns.

Usage

qassertr(x, rules, .var.name)

qtestr(x, rules)

qexpectr(x, rules, info = NULL, label = NULL)

Arguments

x
[list or data.frame] List or data frame to check for compliance with at least one of rules. See details of qtest for rule explanation.
rules
[character] Set of rules. See qtest
.var.name
[logical(1)] Argument name to print in error message. If missing, the name of x will be retrieved via substitute.
info
[character(1)] Extra information to be included in the message for the testthat reporter. See expect_that.
label
[character(1)] Same as .var.name, but passed down to expect_that.

Value

See Also

qtest, qassert

Examples

Run this code
# All list elements are integers with length >= 1?
qtestr(as.list(1:10), "i+")

# All list elements (i.e. data frame columns) are numeric?
qtestr(iris, "n")

# All list elements are numeric, w/o NAs?
qtestr(list(a = 1:3, b = rnorm(1), c = letters), "N+")

# All list elements are numeric OR character
qtestr(list(a = 1:3, b = rnorm(1), c = letters), c("N+", "S+"))

Run the code above in your browser using DataCamp Workspace