Learn R Programming

S7 (version 0.2.1)

S7_inherits: Does this object inherit from an S7 class?

Description

  • S7_inherits() returns TRUE or FALSE.

  • check_is_S7() throws an error if x isn't the specified class.

Usage

S7_inherits(x, class = NULL)

check_is_S7(x, class = NULL, arg = deparse(substitute(x)))

Value

  • S7_inherits() returns a single TRUE or FALSE.

  • check_is_S7() returns nothing; it's called for its side-effects.

Arguments

x

An object

class

An S7 class or NULL. If NULL, tests whether x is an S7 object without testing for a specific class.

arg

Argument name used in error message.

Examples

Run this code
Foo1 <- new_class("Foo1")
Foo2 <- new_class("Foo2")

S7_inherits(Foo1(), Foo1)
check_is_S7(Foo1())
check_is_S7(Foo1(), Foo1)

S7_inherits(Foo1(), Foo2)
try(check_is_S7(Foo1(), Foo2))

if (getRversion() >= "4.3.0")
  inherits(Foo1(), Foo1)

Run the code above in your browser using DataLab