R Language OOP using S3

I wrote an article titled “R Language OOP using S3” in the January 2017 issue of Visual Studio Magazine. See https://visualstudiomagazine.com/articles/2017/01/01/r-language-oop-using-s3.aspx.

r_s3_oop_banner

The R language has been around for decades and is used mostly for interactive data analysis. For example, you could do a linear regression analysis with just two commands — one to load data from a file using the read.table() function, and one to run the analysis using the lm() function.

Because R has evolved over time, there are three different object oriented programming models — S3, S4, and RC. Even though S3 is the oldest and technically weakest OOP model, it’s widely used because many of the built in functions, including lm(), were written using S3.

S3 is very, very different from OOP in any other language. So much so that the first time you look at S3, it doesn’t resemble OOP at all (assuming you’ve seen OOP in Java or Python or C# or almost any other language).

Anyway, in my article I walk readers through an example of creating and using a Person object — the standard beginning OOP example. A side effect of learning S3 OOP is that it gives you some interesting insights into OOP in other languages.

oopusings3demoscreenshot

Advertisements
This entry was posted in R Language. Bookmark the permalink.