When setting options in a function, I have always used the following: opts <- options() on.exit(options(opts), add = TRUE) and assumed it "reset" options to what they were prior to running the function. But for some options that are set to NULL, it does not seem to reset them. Specifically, I have found digits.secs to be set after this simple example below. Is this expected behavior/documented? Overall, this specific example (the one I encountered in the wild) is not that harmful, but I wanted to ask before I set a fix for this in our work
noset = function() { opts = options() print(opts$digits.secs) on.exit(options(opts)) options(digits.secs = 3) } getOption("digits.secs") #> NULL noset() #> NULL getOption("digits.secs") #> [1] 3 John Muschelli, PhD Associate Research Professor Department of Biostatistics Johns Hopkins Bloomberg School of Public Health [[alternative HTML version deleted]] ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel