[R] 'options=utils::recover' not working in .Rprofile or within R

Duncan Murdoch murdoch at stats.uwo.ca
Sat May 30 11:44:22 CEST 2009

[Sent this before completing my last sentence; here's another attempt]

On 29/05/2009 11:45 PM, Mark Kimpel wrote:
> For years I have been using options(error = recover) either in .Rprofile or
> from within R for debugging purposes. The functionality of this appears to
> have changed and I can't recover it (no pun intended) using the ?options
> help page. How can I get the old functionality back, particularly from
> within .Rprofile? A specific line entry would be appreciated. An example,
> the help page, and sessionInfo() follow. Thanks, Mark

I don't think there were any substantial changes in 2.9.0, so I would
guess that you have a local object named "recover" or "options", and it
is causing your  problems.  When I run options(error=recover) and your
two lines below, I get this output:

  > options(error=recover)
  > b.func <- function(x) {y <- x + 2; nonsense; y}
  > b.func(3)
Error in b.func(3) : object 'nonsense' not found

Enter a frame number, or 0 to exit

1: b.func(3)

Selection: 0

which is what you wanted.

To put this into your .Rprofile, you need to use utils::recover (the
utils package hasn't been attached yet).  That also works for me.

There have been changes to recover in R-devel (to become 2.10.0), and 
will likely be more, but what you did shouldn't appear much different 
than what I showed from 2.9.0 above.  If you had sourced the code from a 
file, 2.10.0 should tell you which line of the file contained the error.

Duncan Murdoch

> b.func <- function(x) {y <- x + 2; nonsense; y}
>> b.func(3)
> Error in b.func(3) : object 'nonsense' not found ## in the past this would
> be a menu with numbers for what level I want to go to (in this case just 1)
> This help page states:
> 'error': either a function or an expression governing the handling
>           of non-catastrophic errors such as those generated by 'stop'
>           as well as by signals and internally detected errors... The
>           functions 'dump.frames' and 'recover' provide alternatives
>           that allow post-mortem debugging.  Note that these need to
>           specified as e.g. 'options=utils::recover' in startup files
>           such as '.Rprofile'.
>> sessionInfo()
> R version 2.9.0 (2009-04-17)
> x86_64-unknown-linux-gnu
> locale:
> attached base packages:
> [1] stats     graphics  grDevices datasets  utils     methods   base
> ------------------------------------------------------------
> Mark W. Kimpel MD  ** Neuroinformatics ** Dept. of Psychiatry
> Indiana University School of Medicine
> 15032 Hunter Court, Westfield, IN  46074
> (317) 490-5129 Work, & Mobile & VoiceMail
> (317) 399-1219  Home
> Skype:  mkimpel
> "The real problem is not whether machines think but whether men do." -- B.
> F. Skinner
> ******************************************************************
> 	[[alternative HTML version deleted]]
> ______________________________________________
> 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