Re: [Rd] Loose code in R package files

From: peter dalgaard <PDalgd_at_gmail.com>
Date: Wed, 15 Jun 2011 18:06:22 +0200

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.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes_at_cbs.dk  Priv: PDalgd_at_gmail.com

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Wed 15 Jun 2011 - 16:18:19 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 16 Jun 2011 - 09:10:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive