[R] creating library

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu May 29 18:13:52 CEST 2008


If you mean a package ... 'Writing R Extensions' says

Ideally, the @R{} code files should only directly assign @R{} objects
and definitely should not call functions with side effects such as
@code{require} and @code{options}.

Note that you are expecting the side-effect of 'print', which is called 
when the package is installed and not when it is attached.

On Thu, 29 May 2008, yoooooo wrote:

>
> Hi,
>
>   I'm able to create a library with R CMD INSTALL cmd, etc... I'm just
> wondering.. is it possible that when the user says library(boo), it runs
> some initialization code?
>
>   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
> -- 
> View this message in context: http://www.nabble.com/creating-library-tp17536275p17536275.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-help mailing list