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=F)

REQUIRED ARGUMENTS:
x:
any object, possibly but not necessarily having a class attribute.
what:
a character vector of possible classes.

OPTIONAL ARGUMENTS:
which:
logical flag: if TRUE, the returned value specifies which classes matched.

VALUE:
if which is FALSE, then 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. It is FALSE if x does not have a class.

if which is TRUE, then 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(x, c("formula", "terms"))