[R] on attach/load of a *package*; was creating library

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu May 29 17:30:18 CEST 2008



yoooooo wrote:
> Hi,  
> 
>    I'm able to create a library with R CMD INSTALL cmd, etc... I'm just


You probably mean you are able to *install* a *package*, I guess.


> wondering.. is it possible that when the user says library(boo), it runs
> some initialization code? 


Yes: See the manual writing R Extensions and ?.onLoad and ?.First.Lib 
(depending whether you have a Namespace defined or not).


Uwe Ligges



>    I have a dumb R file that is:
> 
> print(2)
> boo <- function(x){}
> 
>   when I R CMD INSTALL the library, I'm able to see 2 in my unix console..
> but when I do
> 
> library(boo)
> 
>   in R afterwards.. I don't see the 2, but the boo function is there. Is
> there anyways to have the library to run some initialization code when
> loading? Thanks!
> 
> - yoooooooo



More information about the R-help mailing list