Functional Object-Oriented Programming
This chapter describes the use of functional object-oriented programming (OOP) to extend R, covering most practical situations and including the essentials of the implementation. It explores some guidance on combining formal OOP with the earlier S3 implementation. The chapter deals with essentials of programming strategy for classes and for methods. For extending R, packages are once again the key. Class and method definitions in a package are brought into the R process by actions when the package is loaded. If a package contains methods for a particular generic function, those methods will be added to the corresponding generic function object when the package is loaded into the R process. Inheritance of methods is probably the most powerful mechanism in functional OOP. Let's look at the "data.frame" class as an example and compare it to an alternative without inheritance, looking in some detail at how this very popular class has been integrated with R.