[Rd] Run script automatically when package is loaded

Janko Thyson janko.thyson.rstuff at googlemail.com
Sat Mar 12 14:06:58 CET 2011

Dear list,

is it possible to specify a script that is executed "automatically" when my
package is mounted via 'require(my.pkg)' or 'library(my.pkg)'?

Id' like to specify execute a small init function that creates some crucial
environment structures. As it's always the first thing to do when using the
package, I wanted to "hide" it from the user so he won't have to think about
this step.

Can I use the lazy-loading functionality of packages for that (Writing R
Extensions, Section 1.1.5 Data in packages, pp. 10)?

Thanks for any suggestions,

More information about the R-devel mailing list