Learn R Programming

assertive (version 0.1-7)

assert_is_all_of: Alternative version of is.

Description

If a function named is.class exists, call is.class(x). If not, call is(x, class).

Usage

assert_is_all_of(x, classes,
    .xname = get_name_in_parent(x))

  assert_is_any_of(x, classes,
    .xname = get_name_in_parent(x))

  is2(x, class, .xname = get_name_in_parent(x))

Arguments

x
Input to check.
class
Target class that x maybe belong to.
classes
As for class.
.xname
Not intended to be used directly.

Value

  • TRUE if x belongs to the class and FALSE otherwise. assert_is returns nothing but throws an error if x does not have class class.

See Also

is.

Examples

Run this code
assert_is_all_of(1:10, c("integer", "numeric"))
#These examples should fail.
assert_is_any_of(1:10, c("list", "data.frame"))

Run the code above in your browser using DataLab