[R] packaging a package addon

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Oct 30 06:57:31 CET 2003


On Wed, 29 Oct 2003, Ross Boylan wrote:

> I am trying to package some code that is a tweak to the survival
> package.  When I asked earlier, the list consensus was that it would be
> best to do this as a separate package, dependent on survival.
> 
> This is proving a bit tricky.
> 
> I have some run-time and compile time concerns.
> 
> Run-time, my R code needs R code from survival, and my C code needs C
> functions from survival.  Will this all be properly loaded by, for
> example, R CMD check, (assuming the proper dependency in DESCRIPTION) so
> that it doesn't blow up?

No.  It is the responsibility of your package's .First.lib (etc) to load 
any other packages it requires.  DESCRIPTION is used for installation, if 
at all.

The answer would be a bit different if survival were in a namespace.

> The reason I haven't just tried it is that the compile-time issues.  My
> C code depends on survival C code for headers.  I believe that the
> typical target system where the package would be installed won't have
> these at all.  Is that true?  If so, what's the best way around this? 
> Maybe stick the headers in a subdirectory and mess with the build
> options to include them?  And hope they don't get out of sync with the
> real ones?

I think it is worse than that: there is no guarantee that your DLL will be
able to see entry points in an already loaded DLL, as far as I know. The
args for dyn.load(x, local = TRUE, now = TRUE) suggest that at least on
some systems the entry points in survival.so are not shared (and you would
need to alter survival's R code to change that).  Now, you could try to
link independently of R, but on MacOS X a shared module != a dynamic
library, and on Windows and AIX you would need import libraries ....

I would copy the parts of the survival C code you need into your own 
package.

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