> This has the side effect of ignoring errors > and even hiding the error messages. If you > are concerned about multiple calls to on.exit() > in one function you could define a new function > like > withOptions <- function(optionList, expr) { > oldOpts <- options(optionList) > on.exit(options(oldOpts)) > expr # lazily evaluate > }
I wish R had more functions like this. This sort of behaviour is also useful when you open connections or change locales. Ruby's blocks provide nice syntactic sugar for this idea. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ ______________________________________________ R-help@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.