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, Janko
Dirk Eddelbuettel
2011-Mar-12 14:15 UTC
[Rd] Run script automatically when package is loaded
On 12 March 2011 at 14:06, Janko Thyson wrote: | 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)'? That has been possible all along. See help(".onLoad") if you use a NAMESPACE (as you should) or help(".First.lib") if you don't. Dirk | 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, | Janko | | ______________________________________________ | R-devel at r-project.org mailing list | https://stat.ethz.ch/mailman/listinfo/r-devel -- Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
Reasonably Related Threads
- Including data in packages
- WG: Reference classes: error with missing arguments in method calls
- Bug or feature: using "ANY" as a generic field class (was: '[R] Is there a (virtual) class that all R objects inherit from?)
- Stats not loaded? Method for as.ts() results in error
- Avoiding name clashes: opinion on best practice naming conventions