In the January ’14 meeting of the Twente R User group, Janina Torbecke & Inga Schwabe gave an introduction into object oriented programming in R. Although object oriented programming may be more straight forward in other programming languages (e.g. Python, Java, C++), it can be useful in R to enable the use of generic functions (e.g. for your own library), to program efficiently (e.g. elimination of redundant code) or just to produce neat code.
The code that was used to explain the idea of object oriented programming is part of a battleship game made in R. You can find the slides of the presentation here: Object oriented programming in R and the R code here: Battleship game in R.
P.S.: I posted this blog post directly from R, using the simple markdown language and the RWordPress library. To do this, I used the following code:
## Install Rwordpress library if (!require("RWordPress")) install.packages("RWordPress", repos = "http://www.omegahat.org/R", type = "source") ## Load packages & log in on wordpress library(knitr) library(RWordPress) library(XML) # Upload post to blog options(WordPressLogin = c(ingaschwabe = "*****"), WordPressURL = "https://twenterug.wordpress.com/xmlrpc.php") knit2wp("OOP_in_R.Rmd", title = "Object oriented programming in R", publish = TRUE)