ABSTRACT

When using S language to deal with a substantial application, the best approach nearly always involves designing some S functions that work together, and a special class of S objects that represents the essential structure of the data involved in the application. For example, fitting linear models in S requires functions to compute the fitted model and to produce various summary statistics, diagnostics, and plots from the fit. These functions will communicate well with each other if they share knowledge about a class of objects that represent fitted linear models. The process of defining a new class is an informal one. The idea is to establish a minimum set of components or attributes that objects in the new class must have, and to specify what those components or attributes must look like. The degree to which the functions are natural and easy to implement is a good test of how well the class of objects has been designed.