Test for a Class

USAGE:

isClass(what, formal)

ARGUMENTS:

what
string.
formal
logical flag. If TRUE (the default), only formally defined classes qualify. (See discussion of value returned.)

VALUE:

TRUE or FALSE according to whether the string corresponds to a currently defined class. Since S supports both formally and informally defined classes, the test used depends on whether the latter are to be included or not. A formally defined class is one for which a specification exists somewhere in the meta-data for the currently attached chapters. (It need not have slots, and can be a virtual class.)

DETAILS:

An informally defined class also includes any name that has been used as a class name sometime in the current session. In particular, this includes old-style S classes. Because there is no way to determine the existence of these classes except by handling an object that has the class, the value of isClass with formal=FALSE depends on what computations have come before in the session. See the example.

SEE ALSO:

EXAMPLES:

isClass("numeric")  # a class always included with S 

isClass("data.frame")  # an informal, old-style class 

isClass("data.frame", F)  # we haven't encountered it yet 
dim(fuel.frame)  # fuel.frame is a data.frame object 
isClass("data.frame", F)