© Thomas Mailund 2022
T. MailundBeginning Data Science in R 4https://doi.org/10.1007/978-1-4842-8155-0_12

12. Object-Oriented Programming

Thomas Mailund1  
(1)
Aarhus, Denmark
 

In this chapter, we look at R’s flavor of object-oriented programming. Actually, R has three different systems for object-oriented programming: S3, S4, and RC. We will only look at S3, which is the simplest and (as far as I know) the most widely used.

Immutable Objects and Polymorphic Functions

Object orientation in S3 is quite different from what you might have seen in Java or Python or that class of languages. Naturally so, since data in R is immutable and the underlying model in OO in languages such as Java and Python is that you have objects with states that you can call methods ...

Get Beginning Data Science in R 4: Data Analysis, Visualization, and Modelling for the Data Scientist now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.