On Wed, 16 May 2007, Zack Weinberg wrote:
> Is there any way to set options during the evaluation of a particular
> expression, with them automatically reset when control leaves that
> expression, however that happens? Kind of like "let" on a "special"
> variable does in Lisp. I naively tried
>
You could write with_options() as
with_options <-function(optionlist, expr){
oldoptions<-options(optionlist)
on.exit(options(oldoptions))
eval(substitute(expr), parent.frame())
}
and then do
with_options(list(warn=-1), whatever)
-thomas
______________________________________________
[email protected] 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.