Monday, September 13, 2010

post-mortem debugging in R

## to start debugging (browser) right after an error
## set error option to recover


options(error=recover) ## default is NULL


after the error, select which function you want to debug (there will be more than one if the error happened in a function called from the main one)


where: tells you where in the function you are
ls(): lists all the local variables
print(variablename)


## to start debugging at a given point in the function
## insert browser()


myfunction = function(x)
{
   ...
   browser()
   ...
}


http://www.biostat.jhsph.edu/~rpeng/docs/R-debug-tools.pdf
http://www.stats.uwo.ca/faculty/murdoch/software/debuggingR/pmd.shtml

No comments:

Post a Comment

Subscribe via email

Enter your email address:

Delivered by FeedBurner

Followers

Blog Archive

google analytics