Description Usage Arguments Examples
Boolean predicates
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
x |
Object to test. |
.f |
Function to map over the expressions to validate. |
na.rm |
Should |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | f <- function(x, y) NULL
## Require x, y to have the same length
foo <- firmly(f, chk_true(length(x) == length(y)))
foo(runif(3), rnorm(3))
## Not run:
foo(runif(2), rnorm(3))
## End(Not run)
## Require x to contain only non-empty objects
msg <- "{{.}} contains empty objects"
bar <- firmly(f, !! msg := chk_all_map(function(.) length(.) != 0, x))
bar(1:2)
## Not run:
bar(list(1, NULL))
## End(Not run)
## Or more efficiently, in a vectorized manner:
baz <- firmly(f, chk_all("x contains empty objects" := lengths(x) != 0))
baz(1:2)
## Not run:
baz(list(1, NULL))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.