Skip to content
Prev 326876 / 398502 Next

Change R options only inside a package

On 13-07-15 5:27 AM, Helios de Rosario wrote:
I'd recommend that in your own functions that need this, you put this at 
the beginning:

  saveOpts <- options(contrasts = c("contr.sum", "contr.sum"))
  on.exit(options(saveOpts))

This means that the options will be changed just for the duration of the 
call.  If there are situations where users might not want this new 
default, make the new value a default of a function argument.

Duncan Murdoch