Re: [R] creating library

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu, 29 May 2008 17:13:52 +0100 (BST)

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

______________________________________________
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.
Received on Thu 29 May 2008 - 17:44:07 GMT

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 29 May 2008 - 18:30:42 GMT.

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

list of date sections of archive