title: mutable default package values in R
body: <p>I am developing a package for R and I would like to set some package-wide defaults with the ability to modify them later. I know this sounds like global variables and thus evil, but I need this to  control profiling and debugging and to set the backend (the package can use a variety of external program to do its thing and I call them backends).</p>
  
  <p>All these three settings should change at the same time for all the functions in a call stack. For example, if I call <code>mypackage::function1(profiling = T)</code> and <code>function1</code> calls <code>mypackage::function2</code> and <code>mypackage::function3</code> I would like profiling to be on for those too as far as that call is concerned. One solution could be to do
  <code>mypackage::turn.on.profiling()</code> and have all the function refer to some package variable, but it requires trickery with locked environments and stuff like that.</p>
  
  <p>Another could be dynamic scoping, simulated though the <code>sys.frame</code> family of functions (that is, once profiling is on, it's on for anything below that point on the stack). Don't tell me that profiling in R doesn't work like that because this is a different type of profiling, built on top of the existing one but different.</p>
  
  <p>I have no doubt that I can hack it one way or another, but I was wondering if there is a canonical solution or at least some precedent in CRAN for something of this sort so that I won't reinvent the wheel.</p>