0

Possible Duplicate:
General suggestions for debugging R?

I've encountered an error when calling a function from an R package. Briefly,

> library(treemap)
> ...
> tmPlot(X,index=c("r1","r2","r3","r4"),vSize="size")
Error in if (maxI == 1) { : missing value where TRUE/FALSE needed

This SO question gives more details.

I examined the source code of tmPlot by typing tmPlot at the R prompt, but the line that fails doesn't appear in the function. Which means, I assume, that it's failing in some function called by tmPlot.

What's the best way to track this down? For example, can I generate a stack trace somehow? Is there an interactive debugger that will allow me to step through and see where the error happens?

Community
  • 1
  • 1
Lorin Hochstein
  • 57,372
  • 31
  • 105
  • 141
  • 2
    Duplicate of [General suggestions for debugging R?](http://stackoverflow.com/questions/4442518/general-suggestions-for-debugging-r) and [Debugging tools for the R language](http://stackoverflow.com/questions/1169480/debugging-tools-for-the-r-language) and [What is your favorite R debugging trick?](http://stackoverflow.com/questions/1882734/what-is-your-favorite-r-debugging-trick) – Joshua Ulrich Feb 17 '11 at 21:27
  • You mean "package" not library. – Spacedman Feb 17 '11 at 21:31

1 Answers1

1

traceback will print the call stack.

traceback()

Also, have a look at the on-line help for the debug function. Although I have seen better interactive debuggers, there is some basic functionality provided by debug(), debugonce() and undebug()

?base::debug
Andrie
  • 176,377
  • 47
  • 447
  • 496