The class of a data-object determines which functions will process its contents. The class
-attribute is a character vector, and objects can have zero, one or more classes. If there is no class-attribute, there will still be an implicit class determined by an object's mode
. The class can be inspected with the function class
and it can be set or modified by the class<-
function. The S3 class system was established early in S's history. The more complex S4 class system was established later
There are several functions for inspecting the "type" of an object. The most useful such function is class
, although sometimes it is necessary to examine the mode
of an object. Since we are discussing "types", one might think that typeof
would be useful, but generally the result from mode
will be more useful, because objects with no explicit "class"-attribute will have function dispatch determined by the "implicit class" determined by their mode.