OOP in R: A Short Tutorial on S4 Class

This is a hands-on tutorial about OOP in R, giving a short tutorial about S4 class.

Note that S4 class is just one of at least four R’s object systems available to the R programmers: S3, S4, R5, and R6.

The famous Biocunductor folks makes heavy use of S4 classes, but Google, on the other hand, advise to “avoid S4 objects and methods when possible”. Read more OOP in R: A Short Tutorial on S4 Class

OOP in R: An Tutorial about S3 and S4 Classes

This tutorial gives a brief introduction about OOP in R, covering both S3, S4, reference (R5), and R6 classes.

1  S3 Classes

1.1  The basic idea

1.1.1  Class attribute

Everything in R is treated as an object, and one common attribute associated with an object is its class. A class attribute is a character vector giving the names of the classes from which the object inherits. If the object does not have a class attribute, it has an implicit class. For example, Matrices and arrays have class “matrix” or”array” followed by the class of the underlying vector.  Read more OOP in R: An Tutorial about S3 and S4 Classes