My video demo and introductory checklist on how to debug with R and Eclipse IDE

(Last Updated On: June 18, 2012)My video demo and introductory checklist on how to debug with R and Eclipse IDE

Install instructions to debug R with R

Install correct Eclipse version plugin from and follow instructions:

http://www.walware.de/

Also, ensure to install RJ R package dependency as well at.

Ie. Use in R:

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

Note during the Eclipse Stat ET plugin install, it may complain about not finding any dependency plugins. I just installed everything offered as I don’t have time to monkey around with this. My Eclipse version was Indigo or 3.7.

Original testing Rsource came from:

http://navisan.com/Articles/EclipseRHTML.aspx

Once everything is installed and correctly configured within Eclipse, make sure to switch to your Stat ET perspective. I have verified the above does work properly with the correct versions once the plug in and proper Eclipse version is lined up. Don’t forget that R package as well!

If your run test fails, check the trouble shooting guide at the end of  http://navisan.com/Articles/EclipseRHTML.aspx

Note everything runs as it should.

To debug in Eclipse

Go to the near the end of the above link to the optional debug R package to be installed. This is called debug so ensure it is installed in to your R environment. You can do all this from within the R console within Eclipse. Pretty neat. It is not as nice as RStudio’s install package console but you do need to install within Eclipse manually. You obviously use the library R function for this as indicated in this image.

http://navisan.com/Articles/EclipseFiles/Eclipse_RDebuggerLoaded.jpg

Debugging
To debug, make sure your test code is an R function like:

# TODO: Add comment

#

# Author: mark qu

################################################################

# some test code…

myFunction <- function(x)

{

                a = 2

                b = 3

                c = a+b

                c

}

Note the last image screen capture and comments at the end of the navisan.com link:

Debugging with the R debugger under Eclipse StatET. Note the mtrace debug statement, which kicks off the debug session upon the function, and the subsequent function call that is then intercepted by the debugger at the automatic breakpoint at line 1 (breakpoint indicated by the red star). Here we single stepped through the function and are at line 3, indicated by the green bar. Note from the Console window that we at this point examined the contents of variable b.

Also, you may need to set the working directory to your Eclipse R project with setwd and source functions. i.e.

library(debug)

setwd(“C:\Users\xx\workspace\R Project Test”)

source(“test.R”)

mtrace(test)

Loading required package: parser

Also, it seems the launcher run configuration does not load R with a new Eclipse session. If this is the case, just launch manually it within run configuration. Run->Run Configuration and choose Run.

This Eclipse StatET plugin could have bugs so it might not work as expected depending on your plugin and Eclipse version.

[youtube_sc url=”bGkvQw67qKc” playlist=”video, demo, introductory, checklist , how to, debug, R, Eclipse, IDE”]