Skip to content

do.call, browser and traceback

5 messages · Hadley Wickham, Gabor Grothendieck, Brian Ripley

#
A problem that I've encountered when using do.call a lot is very large
stack traces, eg:

f <- function(x) stop()
do.call(error, mtcars)
traceback()
f <- function(x) browser()
do.call(f, mtcars)

I have hacked together my own version of traceback to fix this by
limiting the length of each line to 80 characters, but I can't see any
way to do something similar for browser.  Any suggestions?

Thanks,

Hadley
#
If f is long then you can get some savings like this:

  do.call("f", mtcars)  # note: used "f" rather than f

This does not solve the whole problem but its a step.
On 2/20/06, hadley wickham <h.wickham at gmail.com> wrote:
2 days later
#
Unfortunately, my f is a character vector containing the function I
want to call.  Thanks for the idea though.

Hadley
#
On Mon, 20 Feb 2006, hadley wickham wrote:

            
Did you mean that?  Both are errors.  Perhaps

f <- function(...) browser()
do.call(f, mtcars)

is an actual example of the idea.

What is being used is

 	Rprintf("Called from: ");
 	PrintValueRec(cptr->call,rho);

in src/main/main.c.  We could certainly allow an option to limit the 
deparse length, but I have to say that quite often the useful information 
is well down the list of arguments.  There is currently no user control.

  
    
#
Sorry, yes, that is what I meant.
It would be nice to have some user control - I find the first 100
characters or so is usually sufficient, especially when the real
problem is further down the stack.  It is a real pain when you have
used do.call with a 10,000 row dataframe - and then it is basically
impossible to find the problem by manual inspection anyway.  Even
limiting to 1000 characters would be a big improvement.

Hadley