[R] .First.lib

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Nov 18 18:52:54 CET 2006


On Sat, 18 Nov 2006, Charles Annis, P.E. wrote:

> Greetings:
>
> I’m running R version 2.4.0 (2006-10-03) on WindowsXP in a 3 year old DELL
> box with 2 gig.
>
> I have successfully created a zipped package, mh1823_2.1.zip, using R CMD
> build --binary mh1823.
>
> R CMD build --binary  automatically adds a file, mh1823, containing
> .First.lib and its default function definition.

How does it do that?  (I've never seen it do so.)  What it is documented 
to do is to create a binary package with a file mh1823/R/mh1823 which 
contains code you put in the package sources, so I am pretty sure you 
defined .First.lib.

> I would like to supply my own .First.lib function to create menus when the
> package is loaded by calling my menu-creator function.  It is easy to do
> after the package is installed from mh1823_2.1.zip, but I want my .First.lib
> function to be part of mh1823_2.1.zip in the first place.
>
> Is there a way that I can use R CMD build --binary, with its zip file
> output, but substitute my .First.lib function for the default?

All packages that I am aware of on CRAN which use compiled code have their 
own .First.lib or .onLoad, normally in file R/zzz.R.

-- 
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