Rev 48 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{class}\title{Object Classes}\usage{class(x)class(x) <- namesunclass(x)inherits(x, name)}\alias{class}\alias{class<-}\alias{unclass}\alias{inherits}\description{R possesses a simple generic function mechanismwhich can be used for an object-oriented style of programming.Method despatch takes place based on the class of the first argumentto the generic function.An R ``object'' is a data object which has a \code{class} attribute.A class attribute is a vector of character strings giving thenames of the classes which the object ``inherits'' from.When a generic function \code{fun} is applied to an objectwith class attribute c("first","second"), the system searchesfor a function called \code{fun.first} and, if it finds it,applied it to the object. If no such function is founda function called \code{fun.second} is tried.If no class name produces a suitable function, the function\code{fun.default} is used.The function \code{class} prints the vector of names of classeswhich an object inherits from.Correspondingly, \code{class<-} sets the classeswhich an object inherits from.\code{unclass} returns (a copy of) its argumentwith its class information removed.\code{inherits} indicates whether its first argument inheritsfrom a class with name equal to its second argument.}\seealso{\code{\link{UseMethod}}, \code{\link{NextMethod}}.}