Re: [R] setting options only inside functions

From: <luke-tierney_at_uiowa.edu>
Date: Wed, 27 Apr 2011 15:45:16 -0500

Put together a list and we can see what might make sense. If we did take this on it would be good to think about providing a reasonable mechanism for addressing the small flaw in this function as it is defined here.

Best,

luke

On Wed, 27 Apr 2011, Hadley Wickham wrote:

>> 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
>
>

-- 
Luke Tierney
Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:      luke_at_stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu


______________________________________________ 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.

Received on Wed 27 Apr 2011 - 20:48:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 27 Apr 2011 - 21:50:34 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive