Description Usage Arguments Value Examples
create a new consonance assertion, check, or test
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | consonance_one(
.desc,
.fun,
...,
.var = NULL,
.type = c("test", "assert", "check"),
.level = c("error", "warning", "info")
)
consonance_assert(.desc, .fun, ..., .type = "assert")
consonance_check(.desc, .fun, ..., .type = "check")
consonance_test(.desc, .fun, ..., .type = "test")
|
.desc |
character, test description |
.fun |
function |
... |
arguments to pass into .fun |
.type |
character, type of function, refer to 'checkmate' documentation for the distinction between 'assert', 'check', and 'test' functions. |
.level |
character, action triggered by a failing test |
.value.var |
character, component of a data object to test |
object of class consonance and consonance_test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # define custom a assertion or test
assert_positive <- function(x) {
stopifnot(all(x>0))
x
}
test_positive <- function(x) {
all(x>0)
}
# construct an assertion / test for vectors
vector_assertion <- consonance_assert("vec positive", assert_positive)
vector_assertion
vector_test <- consonance_test("vec_positive", test_positive)
vector_test
# construct an assertion / test for a column ('val') in a data frame
df_assertion <- consonance_assert("df column positive", assert_positive,
.var="val")
df_assertion
df_test <- consonance_test("def column positive", test_positive,
.var="val")
df_test
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.