The new definitive guide for setting up Eclipse, StatET, and R on Windows 7

Quite a while back I wrote some tutorials on getting the StatET plugin for Eclipse running, so that you can write R code and run it within the Eclipse development environment. The developers of all of these pieces of software have kept marching on with the development process, so my walk-throughs are getting a little stale. Luckily, Catherine Dalzell has stepped in with an updated tutorial for getting the most recent versions up and running on Windows 7. See her blog post and the full-fledged pdf tutorial here. Eclipse and StatET are also available for Mac OSX and Linux, and the setup is arguably much easier in those operating systems, so it’s just us Windows holdouts that need hand-holding for the setup process.

The Eclipse + StatET development environment. The main black window contains the R scripts I’m working on. The lower panel is a live interactive R session, where I can type in commands and see the output from R. The left side of the screen houses the file directory and the object browser. The upper right panel holds an outline of the current R script, in this case showing each of the variables I’ve declared. Everything can be rearranged as desired, and the console colors are customizable (I like the black background for some reason).

Just to reiterate why I keep praising Eclipse/StatET despite its rather complicated setup process, I feel that it offers a few extra features that none of the other commonly used R editors have managed to implement correctly yet (I’m looking at you, R Studio developers). Chief among those is the object browser.

The object browser.

Programs like R Studio have something similar, but they still haven’t implemented a nice expandable tree structure like StatET, which lets you really dig through complicated objects like lists and see what’s hiding inside of them. In the image above, I’ve got the output from a lm( ) linear model opened up (the thing called ‘mod’), showing all of the useful little bits returned by lm( ). It gives the class( ) of each object in the list, and tells you the length (or nrow( ) ) of each constituent. You could get the same information in text form using the str( ) command, but the StatET representation is so much more readable. Hovering over an element in the tree will show you the results from a str( ) call as well, so you can immediately see the first few values stored therein, all without having to type that stuff into your R command line. When you start playing with new object types from someone else’s library, this sort of thing is terribly useful for seeing just what they’ve stuffed into their output objects. Navigating through BioConductor’s eSet S4 objects for the first time was infinitely easier when I could see the layout of what was on the inside of an eSet object. Again, these are all things you can do with R’s base functions, it’s just laid out better by StatET.

The other handy feature of StatET is the outline pane, which gives you a nice quick-click directory of where in your script you’ve declared variables. In a Sweave document it will create an outline of your Tex \section{} headers and R code chunks. This makes navigating around inside a long document substantially easier.

A Sweave (.Rnw) document outline.

Just click on any of the list items in the outline to immediately jump to that section of your document.

Otherwise, StatET/Eclipse has all of the features you’d expect from a proper IDE, including lots of keyboard shortcuts for things like submitting single lines of R code to your R session (press Ctrl+R twice), or calling source( ) on the entire script (press Ctrl+R, then Ctrl+S). My new favorite is if you have a long multi-line section of code with nested parentheses or curly braces, you can place the cursor next to a brace, then press Ctrl+Shift+P to jump the matching opening/closing brace. StatET offers code completion, including suggesting object elements when you’re typing code directly into the R command line (i.e. if I start typing myvariable$, StatET will pop up a list of the elements in myvariable, allowing me to tab through and find the one I want).