Object oriented programming in R

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

# 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)

If you want to do try this on your own blog, these are helpful links: http://fredhasselman.com/?p=303 and http://yihui.name/knitr/demo/wordpress/.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s