[R] Scoped options setting?

Thomas Lumley tlumley at u.washington.edu
Thu May 17 15:41:18 CEST 2007

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){
        eval(substitute(expr), parent.frame())

and then do
   with_options(list(warn=-1),  whatever)


More information about the R-help mailing list