[Rd] Loose code in R package files
PDalgd at gmail.com
Wed Jun 15 18:06:22 CEST 2011
On Jun 15, 2011, at 16:22 , Prof Brian Ripley wrote:
> So your example creates an object 'x' in the package or name space. Which is perfectly legal, but maybe not intentional. For example, R's base package does
Yes. Nothing illegal about it, but might be worth noticing that if LazyLoading is used, then the object will be computed only once, while building the package.
So "today <- date()" or "calibrate <- system.time(for(i in 1:1e6)...))" or is a bad idea unless you really want the value at build time on the build computer.
Having results depending on whether or not LazyLoading is being used is probably not a good idea in any case. To have things happen on load, use .onLoad and relatives.
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Email: pd.mes at cbs.dk Priv: PDalgd at gmail.com
More information about the R-devel