inherits
Test Inheritance of an Object

Description

Returns a logical value or an integer vector indicating from which classes x inherits.

Usage

inherits(x, what, which = FALSE)

Arguments

x any object, possibly but not necessarily having a class attribute.
what a character vector of possible classes.
which logical flag: if TRUE, specify which classes matched the object; if FALSE, just say whether any classes matched the object.
Value
if which is FALSE, a single logical value. The value is TRUE if any of the classes in the class attribute of x match (exactly) any of the strings in what.
if which is TRUE, an integer vector of the same length as what that contains the position in the class of x that each value in what matches. A zero is returned for elements of what that dont match any element of the class.
See Also
class.
Examples
# the definition of as.factor 
function(x) if(inherits(x,"factor")) x else factor(x) 
inherits(y~x, c("formula", "terms")) 
Package base version 6.1.4-13
Package Index