Sunday, March 28, 2010

Eclipse setup notes: R (StatEt) and Python (Sage)

My standard Eclipse setup consists of the following extensions:
  • Texclipse
  • StatEt (for R and Sweave)
  • Pydev
  • Data Tools
  • BIRT
And I also have these loaded, even if I don't use them as much
  • CDT (C/C++ Developers tools)
  • Java (since it comes with)
  • Subversion
For a while I've been using StatEt using the R console, because I had not gotten the RJava console to work. While it works, it has two problems (1) it does not open a graphics display, so you could not see the plots you were making (But plots are still generated and included into Sweave documents) and (2) it would drop out if there were any errors in the R code, causing you to have to start over.

The trick with getting RJava to work is set the configuration in the JRE tab in eclipse. In the VM Arguments, there should be an option included that points to rJava (which you have installed and run
sudo R CMD javareconf
to enable)

-Drjava.path=/path.to/rJava

(where the /path.to/ is your path to the location you installed your rJava library in the R directory. On my system it is /home/my_account/R/i486-pc-linux-gnu-library/2.9/ )

This provides a stable interactive R console and allows Sweave.

For Python, in addition to the standard interpreters (python, jython, ipy), you can run Sage. This would be through using the Python interpreter that is in the Sage package.

So add another Python interprester pointing to /sage-4.x.x/bin/python
With $SAGE_ROOT = /path/to/sage-4.x.x
and LD_LIBRARY_PATH = $SAGE_ROOT/local/lib

Next steps, figure out how to add R libraries to the R included in Sage, so R packages can be called from within Sage (note that R can be called using the rpy2 package, but this is only the currently installed packages.)
Post a Comment