Skip to content

IDEs – R and Eclipse

May 7, 2012

R on Eclipse

A fundamental requirement of any good project plan is a reliable and flexible IDE. As a non-EMACS user, two options in particular present themselves. The first of these is RStudio. As of version 0.95 RStudio supports Projects. This greatly increases the IDE’s capacity for project development. The RStudio split windows really come into their own with projects: the project folders are accessible to the bottom right; the SVN facility is available in a tab in the top right window. These features make RStudio perfect for R-only packages. However, for integrating C or C++ with R, it is still does not offer a universal development environment. For our project we want to incorporate the Rcpp package to use C++ IO in R. The solution is to run R through Eclipse. This is not as straight-forward as RStudio, but is feasibly implementable and highly worthwhile, given the resulting development environment. I will outline 3 features: StatET‘s R Console in Eclipse, Rcpp packages, and, briefly, SVN. I am running Ubuntu 12.04 with Eclipse 3.7 and R 2.15. Despite the fact that these releases are relatively recent, there are no considerable obstacles to making Eclipse an all-round environment for integrating R and C++ code and checking it in and out of R-Forge.

Good guidelines as to how to implement these features already exist, so here I will simply link to these sources, give some context, and describe a few changes I found necessary for my installations of Ubuntu, Eclipse, and R.

1. StatET

Stephan Wahlbrink’s StatET provides an R IDE on the Eclipse platform providing an R console and package building capabilities. Using R 2.15 and Eclipse 3.7 the testing version 3.0 of StatET was required. However, it seems to work fine for me thus far.

Oneliner provides a really useful article on StatET here , and installation instructions are available from  Wahlbrink’s site.

Don’t forget to: install.packages(c(“rj”, “rj.gd”), repos=”http://download.walware.de/rj-1.1″).

Note, that rj 1.1 is necessary with the above installations. However this requires the test release of StatET 3.0, available from the downloads page

Once installed it is easy to configure consoles for packages etc. For more details see L Lam’s A guide to Eclipse and the R plug-in StatET .

2. Rcpp on Eclipse

Fellows Statistics provides an excellent description of how to implement Rcpp and RInside on Eclipse for MacOSin a <a href=”http://blog.fellstat.com/?p=170“> recent post. </a> The steps were mostly the same for Ubuntu, with, in my case, the following exceptions:

a) Do not add the -arch x86_64 flags.

b) As stated by Fellow Statistics, change the installation and linking directories as required:  e.g. usr/lib/R, ~R/2.15/Rcpp/install etc.

c) In order to get the linker to work, you may need to add extra flags. Dirk Eddelbeutel’s <a href=”http://r.789695.n4.nabble.com/Including-Rcpp-in-Eclipse-C-project-td1569475.html“> advice in this post</a> was invaluable here, i.e. make the RInside examples and look at the flags used for installation. In my own case, the addition of several -l options was necessary and sufficient for the linker to work.

d) Finally, Eclipse had problems finding libRcpp.so at run-time. The solution was to add  LD_LIBRARY_PATH to the location of  libRcpp.so to the environment variables in Run/Debug Settings.

Granted the above, it works great, and provides an excellent environment for building R packages. Both R and C++ code is compilable and easy to debug. Also, the package structure is readily accessible and easy to manipulate and build. One drawback with Rcpp is that there can be a bit of a curve from using it inline to using it in packages, and it is easy to overuse/misuse inline in cases where modules or packages are more appropriate. With this setup it is easy and intuitive to build code in packages from the get go, as it is more or less the same experience as building an Eclipse Java or C++ project.

3 SVN in Eclipse

This is pretty easy. The two main options are Subversive and Subclipse. I chose the latter based on a preliminary (and by no means conclusive) examination of the extensive debate as to which is better. It installs easily, given the dependencies. It works intuitively and, most importantly, as far as I can tell it works, allowing me to connect to R-Forge and checkout repositories. For a useful tutorial see here.

Interestingly, its dependencies include Mylyn - a task management tool I was not aware of, and which I may use for the project plan etc. in the next few weeks.

In conclusion, taking the Eclipse route gives a wider range of options to those available on RStudio. Pretty much all of the latter’s features are replicable, and it is also possible to create a comprehensive environment for integrating cross-language code.

About these ads

From → Uncategorized

Leave a Comment

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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: