Eclipse – an alternative to RStudio – part 1

Many R users enjoy working in RStudio, but it’s not your only option for reproducible research in R. Stephen Wahlbrink has written a plugin for Eclipse, Statet, that offers similar functionality to RStudio within the popular Eclipse framework. You can run an R console, debug a script, compose a document in LaTeX with R code chunks, and link the two through Sweave and the plugin. Statet first appeared in 2005. It continues to be supported and typically updates with new versions of Eclipse. Development is not as rapid as with RStudio, but new features do appear from time to time. Support for R Markdown has been added recently. You can also take advantage of other Eclipse plugins, such as the spell checker or support for Git. For people who already use Eclipse for development work, Statet could be an attractive choice.

Installation guide

I have used both Statet and RStudio extensively. They offer similar functionality and similar ease of use. RStudio has some nice features that Statet lacks, but my experience with RStudio has been disappointing in terms of stability and proneness to crashing. Statet has 11 years behind it, as well as the stability of the Eclipse framework itself. RStudio is certainly easier to get up and running. Eclipse can be tricky to configure, especially if you have not used it before. No worries: this tutorial will walk you through every step of the way.

The instructions shown here are based on a clean install of Kubuntu 16.04 and current versions of everything else, as of May 2016. These instructions should work for any Debian based distro. Most of this will also work with Fedora/Centos/RHEL, but I have sometimes found it harder to get up to date versions of things from the repositories these distros use.

Eclipse is cross-platform and this stack is also available to Windows users. The installations are similar, and I specify the differences in the details section. I have used Eclipse/R/Statet on a Windows system without administrator privileges and behind a firewall. I suggest tips for other users in similar controlled environments.

Here is an overview of the what you need to do.

  • Install Java.
  • Get Eclipse.
  • Install R
  • Obtain a LaTeX distribution
  • From within Eclipse, install the Statet plugin.
  • From within R, install packages rj and rj.gd from Walhbrink’s site.
  • Launch Eclipse and configure for use with R and LaTeX

Warning: Don’t mix the bitage. Go 64 bit on everything, or 32 bit.

Most of the time, if I have an issue with installing Statet and Eclipse, it’s because I mixed 32 and 64 bit applications. The rest of the time, problems came from badly installing Java.

Install Java

On windows, you only need the runtime version (JRE) and you probably have this already. On Linux, you need the JDK, because R needs the JDK to compile the rj and rj.gd packages. On Ubuntu-based distributions, the following code installs Oracle’s JDK and configures the system. Kudos to Salem from AskUbuntu for this.

Open a terminal and enter:

sudo apt-add-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
sudo R CMD javareconf

The first line adds the PPA for webupd8. The second line refreshes apt-get. The third line installs the Java 8 installer and Oracle’s Java 8. The export line tells the system where to find Java, and the final line tells R. Done.

Get Eclipse : Download the current version from Eclipse.org. Linux users now get an installer for Eclipse. Extract the folder and run the script eclipse-inst. The “installer” creates a folder in your home directory called eclipse. No root privileges are required. There is a script, also called eclipse, that launches the IDE. You can create a desktop link to the script, if you like. The installation has helpfully provided an icon you can use to decorate your launcher.

Linux users : Avoid sudo apt-get install eclipse and download directly from the site. The repos are sometimes out of date.

Install R

You probably know how to do this already. A note to Windows users in controlled environments. Most of this can be done by users without administrative privileges. However, you will save yourself some trouble later on if you can convince your IT department to do the install for you. They can ensure that the location of your R install is preserved in the Registry. This makes it a lot easier for Eclipse to find R when you want to summon the console.

Install a LaTeX distribution

Windows users can install MikTex 2.9 from the installer. If you work behind a firewall, be sure to get the complete installation. The default provides a basic selection of packages and installs the rest as needed, on the fly. Your firewall won’t like that.

Warning! The Recommended Download is the 32 bit version. If you are going 64 bit, be sure to download the 64 bit version under Other Downloads.

Linux users can use the version from the repo. If you use the synaptic package manager, go for texlive and texlive-extras, plus any other packages you expect to need. Texlive won’t install packages on the fly, so you need to get all the packages you use up front.

Extra instructions for Windows users

Windows users also need to inform Miktex where to find the Sweave.sty file. To do this:

  • Open Miktex Settings. This program comes with the Miktex installation. There is another program called Miktex Settings (Admin). Ignore this one and use the plain Miktex Settings.
  • Select tab Roots.
  • Click Add and navigate to folder ..\my R installation\share\texmf
  • Select this folder, save and exit Miktex Settings. You’re done.

You may have noticed that Sweave.sty is not actually in the texmf folder. It’s a couple of folders lower down, but this is the folder that Miktex needs to know about.

Installing the Statet plugin

From Eclipse, install the Statet plugin. As with rj, the plugin can be downloaded and installed manually, or installed on the fly from Eclipse. You want the version that works with the version of Eclipse that you previously installed. In most cases, you will be using the current version of Eclipse with the most recent version of Statet, but if you have reason to maintain a legacy system, earlier versions of Statet are still available on Walware.

In the following screenshots, I install the current version for use with Mars Eclipse. You can click on the images to enlarge them.

Check Walware for the current version of statet and copy the download url. The cursor on the my screenshot (low and center) points towards the line I need to copy.
Kazam_screenshot_00002

Now launch Eclipse. Select Help -> Install New Software.
Kazam_screenshot_00001

Click Add (top right). A form opens where you paste the URL from Walware. You can also give the plugin a name. On the screenshot, I’m about to click OK.
Kazam_screenshot_00003

Eclipse goes onto the Internet and retrieves some information from Walware. It finds 5 plugins. Check the box beside Statet. Do not select the other boxes.
Kazam_screenshot_00004

Click Next. The plugin will now download and install. Various screens will appear asking you to agree to the license and warning about unsigned content. Agree to everything and accept everything. Congratulations! You have Statet.

While we’re installing things, let’s grab Ahti Kitsik’s word wrap plugin. As before, select Help -> Install New Software. Click Add and insert Ahti’s download url for the plugin, http://www.ahtik.com/eclipse-update/. Give it a useful name, click OK and proceed as before.
Installing Ahti Kitsik's word wrap plugin.

Now exit Eclipse to complete the installation.

Install R packages rj and rj.gd

rj and rj.gd are R packages used to form a bridge between R and Java. You need these to run the R console from Eclipse. These packages are not hosted on Cran, and you need to download them from www.walware.de. Note that this step only works after Statet has been added to Eclipse.

  • Launch R
  • Navigate to Wahlbrink’s download page for rj and rj.gd.
  • Copy the appropriate install code for the version you need and paste into your R console. Typically, you want the first line in the list. The other options refer to earlier versions of Statet, used with earlier versions of Eclipse. At the time of writing, you would enter the following code at the R prompt.
  • install.packages(c("rj", "rj.gd"), repos="http://download.walware.de/rj-2.0")
    • Quit R

Under Linux, the previous step may take a few moments while the packages compile. You may get an error message to the effect that the system could not compile a simple JNI program. This means that you failed to correctly install the Java JDK, or that R cannot find it. Googling the error message leads to a helpful post on Stack-Overflow, which should resolve the issue. Basically, you need to run sudo R CMD javareconf before attempting to install rj and rj.gd.

If you work behind a firewall, you can do a manual install by downloading the packages from Walware through your browser, .

Configuring Eclipse

We have all the tools, but we’re not done yet. We still need to configure Eclipse so that it knows:

  • Where to find the R version you are using
  • How you want to run R (from which folder, with which Java, etc.)
  • Where to find LaTeX and how to run it.

If you have never used Eclipse before, it is easy to get lost at this point. I have supplied detailed instructions with screen shots in part 2 of this tutorial.

28 Comments

  1. I
    Intoxinator July 27, 2016

    I hated Eclipse when I was a Java dev. So bloated and slow. If the Jetbrains guys ever come up with an IDE for R, I’ll consider switching from R Studio, but Eclipse? Never.

    Reply
  2. CB
    Chris Beeley July 23, 2016

    Oh, is that what dual monitor support means? I knew about that. I had visions of something even cooler in my head

    Reply
    1. YX
      Yihui Xie July 24, 2016

      Yep, you are free to tear off an editor tab and pull it on another monitor now.

      Reply
      1. F
        frank_hjy April 5, 2017

        Just now I tried “tearing off” an editor tab in RStudio v1.0.44. It worked, but then I couldn’t put it back. (In Eclipse you can easily put views/subwindows back.) So I restarted RStudio, but then I was unable to tear off a tab at all.

        Reply
  3. A
    AlexF July 23, 2016

    1. OS: Windows. I use Eclipse+StatET and not RStudio simply because Eclipse has much richer UI functionality. After Eclipse, in RStudio I feel shackled. (Although debugging is much better in RStudio).
    2. My biggest difficulty is in installing new Eclipse version. There are so many choices (IDE for Java, IDE for C++, …) which I do not need — and it is hard to find a barebone version.

    Reply
    1. CD
      Catherine Dalzell July 23, 2016

      The IDE for Java at the top of the list seems to be the vanilla option. I put Statet on it.

      Reply
  4. MB
    M Edward/Ed Borasky July 23, 2016

    1. If your workload is predominantly R, you’re better off with RStudio.
    2. If you have a significant amount of Java or other JVM code you’re better off with Eclipse. This includes native Android.
    3. If you want to do data science in R and Python, you’re better off with Jupyter.

    I do think “vendor lock-in” is a problem with RStudio / R Markdown / Shiny. But you can do almost anything in the whole environment – dashboards, interactive apps, scholarly LaTeX publication, high-performance workstation computing, interface to cloud machine learning, etc. – as long as you’re willing to accept R as your client language and sometimes deployed in servers.

    Reply
    1. D
      Dave July 23, 2016

      I think that’s a really good summary, agreed. Although the issue of vendor lock-in seems a bit of a stretch. You can always compile rstudio yourself if you like.

      Reply
      1. MB
        M Edward/Ed Borasky July 23, 2016

        Yes, I know I can compile RStudio myself – in fact, I have, since RStudio don’t support RStudio Server on Fedora Linux. But their licensing / trademark policy means that it’s essentially for personal use only. I don’t see any hope of a Linux distro packaging RStudio, but they *all* have Eclipse and IPython notebooks.

        Reply
  5. J
    Jeff July 22, 2016

    I agree with the rest of the comments. This post seems somewhat ill-informed, as all the limitations cited by the author really aren’t limitations,nor have they been for months/years.

    There might be any number of reasons to take the author’s recommendations for eclipse, but the reasons cited certainly aren’t amongst them. Maybe parts 2 and beyond will provide a more compelling case.

    Reply
    1. CD
      Catherine Dalzell July 23, 2016

      The point of the tutorial is not to convince happy RStudio users to switch but to apprise people of a lesser known option that some might prefer. RStudio gets better all the time, but Statet exists and has merit. It is poorly documented and hard to set up, which is why I wrote the tutorial. I used RStudio all day every day for 6 months in 2015 on Windows 7, i7, and switched back to Eclipse because of frequent crashing. And the pdf graphs, which I honestly could not get to work.

      Reply
  6. D
    Dave July 22, 2016

    It’s true that eclipse is good for programming in multiple languages, but in my experience that is where the benefits relative to rstudio end. I’ve been using rstudio and rstudio server on windows and linux for a few years now and don’t have crashing issues.

    Also, anything that requires me to install java sends me looking for alternatives immediately.

    Reply
    1. MB
      M Edward/Ed Borasky July 23, 2016

      Honestly I think RStudio is overkill on Windows – the Windows R GUI has been adequate as an IDE for many years, and the “installr” package makes installing dependencies like MikTeX easy.

      And Eclipse is *humonogous* – if it were just the JVM it’d be fine – I need that for Java-based R libraries anyhow. But it’s much more than just the JVM!

      Reply
      1. IF
        Ian Fellows July 23, 2016

        I have to respectfully disagree. The Windows R GUI is straight out of 1997. From a usability perspective, RStudio wins without even leaving the gate. In fact, almost anything is superior to the windows GUI.

        Reply
        1. CD
          Catherine Dalzell July 23, 2016

          To me, the value add is embedding code in documents – either rmarkdown or sweave. Another solid option is to use the package structure to organize a data analysis. That way, you can keep track of what you have done. RStudio makes this very slick, as does Statet.

          Reply
        2. PS
          Peter Sherick July 25, 2016

          The only good thing about RGui is floating windows for plotting on a lower res screen. But I don’t know why anyone wouldn’t use RStudio’s easy package builder. Was gonna try eclipse, but too lazy to mess with proxy settings.

          Reply
  7. IF
    Ian Fellows July 22, 2016

    I would also add that eclipse is a superior option for developing in a mixed language environment. For example if you are coding packages with a mix of R, Java, C, C++, etc. My general feeling is that for a data analysis project, I usually will fire up RStudio or a terminal window. For true data engineering I’ll fire up Eclipse.

    Reply
  8. B
    Burak July 22, 2016

    Detaching your work is also possible in RStudio. Look at the top left corner of the editor windows

    Reply
    1. F
      frank_hjy April 5, 2017

      In Eclipse you can detach any type of subwindow, not just an editor one. And you can put them back where they came from. This is a major benefit of Eclipse for me.

      Reply
  9. GT
    Gregor Thomas July 22, 2016

    The Eclipse part of the article is very good, but the RStudio comparison seems ill-informed.

    I was most surprised by “RStudio will not produce a pdf from LaTeX that contains R generated graphs”. I’ve been using LaTeX in RStudio to produce PDFs with R-generated graphs since 2012 (usually .Rnw -> (knitr) -> .tex -> (XeLaTeX) -> PDF, using called from a hotkey in RStudio, specifying XeLaTeX as my preferred compiler in the RStudio preferences).

    Reply
    1. CD
      Catherine Dalzell July 23, 2016

      It didn’t work for me but I didn’t try XeLaTeX. That’s good to know.

      Reply
      1. GT
        Gregor Thomas July 23, 2016

        I use XeLaTeX for the ease of using extra fonts, but I haven’t had issues with Rnw -> TeX -> PDF using regular LaTeX either.

        Reply
      2. YX
        Yihui Xie July 24, 2016

        You are welcome to say “it didn’t work for me” (we will be happy to help you find out why if you can provide your environment info and a minimal reproducible example), but I think it is very misleading to say “it does not work” and imply it was a bug. How could we possibly miss this obvious issue if it is real? Although R Markdown seems to be more popular than Rnw/LaTeX, there is still a fair amount of users who work with Rnw/LaTeX in RStudio. Personally I don’t recall any reports on this issue.

        Reply
        1. CD
          Catherine Dalzell July 24, 2016

          I spent three days on the issue and found other people with the problem by way of Google. Couldn’t find a solution on the web. The same code chunks worked with Markdown and HTML. It was easier to go back to Eclipse, which works FOR ME and does not crash ON ME. It was a real issue FOR ME.

          Reply
  10. RF
    Robert Flight July 22, 2016

    I’m sorry, have you tried getting Java working nicely on Linux? It can be a nightmare, especially if different software wants different things. RStudio, in contrast has been very easy to install.

    Also, regarding multi-monitor, it is now possible to split out editor windows into their own frame, making it much nicer to work on a multi-monitor setup.

    But good to know there are alternatives.

    Reply
    1. CD
      Catherine Dalzell July 23, 2016

      I agree. I have spent hours getting Eclipse and Statet to work on Linux and Windows. Every step in my tutorial comes from a nightmare of failure and googled error messages – beginning with Java. I wrote this in the hope of sparing some pain to other users. It would be a shame to pass up a tool just because the setup is tricky.

      Reply
      1. D
        Dave July 23, 2016

        It would be nice if all that java/eclipse/statet stuff was already baked into a dockerfile.

        Reply
  11. CB
    Chris Beeley July 22, 2016

    I’m surprised to hear that RStudio crashes a lot for you, I’ve never really had problems on that side. Moreover, on the rare occasions I have found it has crashed it has always kept all my work intact, even if I haven’t saved recently.

    I don’t have any issues generating documents with plots in LaTeX either. I’m using RStudio on Linux, though, perhaps it’s more stable and better integrated with LaTeX on Linux, I’m not sure.

    I seem to remember compiling LaTeX with figures on Windows back when I used Windows, but perhaps I’m not remembering correctly.

    Just thought I would stick up for the Linux version of RStudio, at least. I certainly know what you mean about dual monitor support, I would love to see that in RStudio.

    Reply

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.