> From: h.wick...@gmail.com [mailto:h.wick...@gmail.com] On > Behalf Of Hadley Wickham > Sent: Wednesday, April 27, 2011 2:21 PM > To: luke-tier...@uiowa.edu > Cc: William Dunlap; r-help@r-project.org > Subject: Re: [R] setting options only inside functions > > > 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. > > In devtools, I have: > > #' Evaluate code in specified locale.
S+ has a Sys.withlocale() that is a bit more general than your with_locale(): > Sys.withlocale function(expr, category = "LC_ALL", locale) { cur.locale <- Sys.getlocale(category) on.exit(Sys.setlocale(category = category, locale = cur.locale)) Sys.setlocale(category = category, locale = locale) expr } > with_locale <- function(locale, expr) { > cur <- Sys.getlocale(category = "LC_COLLATE") > on.exit(Sys.setlocale(category = "LC_COLLATE", locale = cur)) > > Sys.setlocale(category = "LC_COLLATE", locale = locale) > force(expr) > } > > (Using force here just to be clear about what's going on) > > Bill discussed options(). Other ideas (mostly from skimming > apropos("set")): > > * graphics devices (i.e. automatic dev.off) Also, for setting and restoring graphics parameters with par(). > * working directory (as in the chdir argument to sys.source) > * environment variables (Sys.setenv/Sys.getenv) > * time limits (as replacement for transient = T) ______________________________________________ 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.