The <i>class</i> of an object



next up previous contents
Next: Categories and factors Up: Objectstheir modes Previous: attributes() and attr()

The class of an object

A special attribute known as the class of the object has been introduced in the August 1991 release of S and S-PLUS to allow for an object oriented style of programming in S-PLUS.

For example if an object has class data.frame, it will be printed in a certain way, the plot() function will display it graphically in a certain way, and other generic functions such as summary() will react to it as an argument in a way sensitive to its class.

To remove temporarily the effects of class, use the function unclass(). For example if winter has the class data.frame then

winter

will print it in data frame form, which is rather like a matrix, whereas

unclass(winter)

will print it as an ordinary list. Only in rather special situations do you need to use this facility, but one is when you are learning to come to terms with the idea of class and generic functions.

Generic functions and classes will be discussed further in §gif, but only briefly.



Erik Moledor
Tue Jan 31 21:02:18 EST 1995