Skip to content
Prev 59485 / 63430 Next

Checking multiple inheritance of S4 objects using R's C API

Emre,

inherits() was designed for S3 classes and at C level only ever works for S3 classes.

In S4 world you should use is().

There is no equivalent C-level API for is() so, unfortunately, you likely have to use Rf_eval() of is(x, "class").

At low-level there is R_S4_extends() which allows you to get the list of superclasses for S4 objects, but according to the definition of some people it is not part of the official R API so your mileage may vary.

Cheers,
Simon