[R] Stack trace?

Kevin Burton rkevinburton at charter.net
Thu Nov 10 16:10:58 CET 2011


Will traceback() work in the error routine specified in tryCatch?

error <- function(e)
{
    traceback()
}

tryCatch(..., error=error)

-----Original Message-----
From: William Dunlap [mailto:wdunlap at tibco.com] 
Sent: Wednesday, November 09, 2011 5:09 PM
To: Thomas Lumley; rkevinburton at charter.net
Cc: r-help
Subject: RE: [R] Stack trace?

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Thomas Lumley
> Sent: Wednesday, November 09, 2011 1:53 PM
> To: rkevinburton at charter.net
> Cc: r-help
> Subject: Re: [R] Stack trace?
> 
> On Thu, Nov 10, 2011 at 10:35 AM,  <rkevinburton at charter.net> wrote:
> >
> > Currently I have a for loop executing functions and at the end I get 
> > a message like:
> >
> > There were 50 or more warnings (use warnings() to see the first 50)
> >
> > If I do what it says and type warnings(), I get 50 messages like:
> >
> > 2: In !is.na(x) & !is.na(rowSums(xreg)) :
> >   longer object length is not a multiple of shorter object length
> >
> > I am not sure what function these errors are originating from. I 
> > don't think it is from any of the 'R' script that I wrote. I would 
> > like to see which function is being called when this error is thrown 
> > and which called that . . . and so on.
> >
> > I have the same problem with error messages. An error is thrown but 
> > I don't have a call stack to help trace down the problem. Is there 
> > some function or technique that I could use to help get a call stack?
> 
> traceback() gets you a stack trace at the last error
> 
> options(warn=2) makes warnings into errors
> 
> options(error=recover) starts the post-mortem debugger at any error, 
> allowing you to inspect the stack interactively.

And
  options(warning.expression=quote(recover()))
will start that same debugger at each warning.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

 
>   -thomas
> 
> --
> Thomas Lumley
> Professor of Biostatistics
> University of Auckland
> 
> ______________________________________________
> R-help at r-project.org mailing list
> 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.



More information about the R-help mailing list