Description Usage Arguments See Also Examples
Type predicates
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | chk_null(x)
chk_not_null(x)
chk_symbol(x)
chk_pairlist(x)
chk_closure(x)
chk_environment(x)
chk_language(x)
chk_atomic(x, n = NULL)
chk_vector(x, n = NULL)
chk_logical(x, n = NULL)
chk_boolean(x)
chk_numerical(x, n = NULL)
chk_number(x)
chk_integer(x, n = NULL)
chk_integerish(x, n = NULL)
chk_double(x, n = NULL, finite = NULL)
chk_complex(x, n = NULL)
chk_character(x, n = NULL, encoding = NULL)
chk_string(x)
chk_list(x, n = NULL)
chk_raw(x, n = NULL)
|
x |
Object to test. |
n |
Length. |
encoding |
Encoding of a string or character vector. One of |
finite |
Whether values must be finite. Examples of non-finite values
are |
rlang type predicates, which underlie the
length-dependent predicates (except chk_numerical()
)
Object predicates, for verifying identities that are
not characterized by type, e.g., data frames, which have type list
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | f <- function(x, y, z) NULL
## Require all arguments to be integer (vectors)
foo <- firmly(f, chk_integer())
foo(0L, 1:2, length(letters))
## Not run:
foo(0L, c(1, 2), length(letters))
## End(Not run)
## Require all arguments to be scalar integers
bar <- firmly(f, chk_integer(n = 1))
bar(0L, 1L, length(NA))
## Not run:
bar(0L, 1L, lengths(letters))
## End(Not run)
## Require x, y to be character (vectors), and z to be an length-1 list
baz <- firmly(f, chk_character(x, y), chk_list(n = 1, z))
baz(letters, "text", list(1))
## Not run:
baz(0, "text", list(1, 2))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.