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:> 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 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >
> If f is long then you can get some savings like this: > > do.call("f", mtcars) # note: used "f" rather than f >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:> 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)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.> > 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 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
> Did you mean that? Both are errors. Perhaps > > f <- function(...) browser() > do.call(f, mtcars)Sorry, yes, that is what I meant.> 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.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