do.call, browser and traceback

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

do.call, browser and traceback

hadley wickham
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: do.call, browser and traceback

Gabor Grothendieck
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 <[hidden email]> 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
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: do.call, browser and traceback

hadley wickham
> 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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: do.call, browser and traceback

Brian Ripley
In reply to this post by hadley wickham
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
>
> ______________________________________________
> [hidden email] 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,                  [hidden email]
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: do.call, browser and traceback

hadley wickham
> 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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Reply | Threaded
Open this post in threaded view
|

Re: do.call, browser and traceback

Sigbert Klinke
Hi,

I run in the same problem, as discussed in 2006. Is there any solution
by now?

Sigbert

Am 23.02.06 um 20:39 schrieb hadley wickham:

>> 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
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

--
https://hu.berlin/sk
https://hu.berlin/mmstat3


______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.