Classes and Methods in R
This chapter covers the basic computations needed for object-oriented programming (OOP) in R. It considers the two versions of OOP and the choice between them in an application. Common encapsulated OOP languages treat objects as mutable references; that is, methods and other software have the ability to modify the object on which the method is invoked through a reference to that object. In contrast, when the software is built on a functional version of OOP, user computations with the object are naturally via function calls. The goal of object-oriented classes and methods is now to generalize commonly occurring functions to deal with an open-ended variety of objects. Models fitted to data are essentially functional: the object as a whole represents the functional result of some fitting algorithm. Functional languages such as Haskell tend to have a syntax that does not include procedural modification of objects.