[R] setting options only inside functions
luke-tierney at uiowa.edu
luke-tierney at uiowa.edu
Wed Apr 27 22:45:16 CEST 2011
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
More information about the R-help
mailing list