inherits(x, what, which=F)
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.
# the definition of as.factor function(x) if(inherits(x,"factor")) x else factor(x)inherits(x, c("formula", "terms"))