[R] access environment in which an error occoured

Jannis bt_jannis at yahoo.de
Fri Apr 25 14:31:53 CEST 2014


Dear R users,


is there any way to access/print/save the content of an environment in 
which an error occoured? Image the following testcase:


test =  function() {
   b =  3
   plot(notavailable)
}


dump.frames.mod = function() {
    save(list=ls(parent.frame(1)), file='dummy.RData')
}
options(error = quote({dump.frames.mod()}))

test()

The call to plot() here would create an error in which case I would like 
to save the whole environment in which it occoured (in this case only 
the object b) to some file for later debugging. The way I tried to 
implement it above, only the content of the global environment is saved 
(probably because dump.frames.mod is called from this environment). Is 
there any way to save the content of the environment down in the stack 
where the error actually occoured? I know about the dump.frames() 
function which somehow does not work this case (see my earlier post: 
http://r.789695.n4.nabble.com/maximum-size-of-dump-frames-files-td4689444.html).


Thanks
Jannis




More information about the R-help mailing list