Learn R Programming

testthat (version 0.2)

is_a: Expectation: does the object inherit from a class?

Description

Expectation: does the object inherit from a class?

Usage

is_a(class)

Arguments

class
character vector of class names

Details

Tests whether or not an object inherits from any of a list of classes.

See Also

inherits

Examples

Run this code
expect_that(1, is_a("numeric"))
a <- matrix(1:10, nrow = 5)
expect_that(a, is_a("matrix"))

expect_that(mtcars, is_a("data.frame"))
# alternatively for classes that have an is method
expect_that(is.data.frame(mtcars), is_true())
# doesn't read quite as nicely}

Run the code above in your browser using DataLab