Description Usage Arguments Details Value Examples
This function returns TRUE
if the variable values are correct and FALSE
otherwise.
1 2 3 4 5 6 7 |
x |
(any) The object with elements to test |
values |
(any) The allowed (or not allowed) values. |
min |
(numeric, optional) The minimum allowed value for a range. If
|
max |
(numeric, optional) The maximum allowed value for a range. If
|
n |
(integer, optional) The allowed length. If |
n_min |
(integer, optional) The allowed minimum length. If |
n_max |
(integer, optional) The allowed maximum length. If |
The following values can be checked:
is_na()
: Elements of 'x' must be NA
.
is_in()
: Elements of 'x' must in specified values
.
is_in_range()
: Elements of 'x' must be in the specified numeric range.
has_char_length
: Elements of 'x' must have valid character length. You
can specify the exact length using n
or the minimum and/or maximum length
using n_min
and n_max
respectively.
TRUE if elements in x are in y, FALSE otherwise
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 | # TRUE
is_na(NA)
is_na(c(NA, NA))
# FALSE
is_na(NULL)
is_na(1)
is_na("foo")
is_na(c(1, NA))
# TRUE
is_in("a", letters)
is_in(c("a", "b", "c"), letters)
# FALSE
is_in(1, LETTERS)
is_in(1:2, LETTERS)
# TRUE
is_in_range(1, min = 0)
is_in_range(c(1.1, 2.2, 3.3), min = 0, max = 10)
# FALSE
is_in_range(0, min = 1)
is_in_range(c(1.1, 2.2, 3.3), min = 2, max = 3)
# TRUE
has_char_length("", 0)
has_char_length(c("some", "text"), 4)
has_char_length(c("some", "text"), n_min = 1)
has_char_length(c("some", "text"), n_max = 10)
has_char_length(c("some", "text"), n_min = 1, n_max = 10)
# FALSE
has_char_length("sometext", 4)
has_char_length(c("different", "text"), n_min = 5)
has_char_length(c("different", "text"), n_max = 5)
has_char_length(c("different", "text"), n_min = 5, n_max = 8)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.