R’s approach to object-oriented programming is through generic functions and classes. As mentioned in the introduction, R actually has three systems for implementing this, called S3, S4, and R6. In this chapter, I will only describe the S3 system, which is the simplest of the three, but I will return to the other two systems in later chapters.
Generic Functions
The term generic functions refers to functions that can be used on more than one data type. Since R is dynamically typed, which means that there is no check of type consistency before you run your programs, type checking ...