[R] building an R package : where and how should my fortran library be loaded ?

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Oct 22 12:42:20 CEST 2004


On Fri, 22 Oct 2004, Gilles GUILLOT wrote:

> I'm currently trying to make available 
> a few fortran subroutines and R functions 
> (which make interface to these subroutines),
> as an R package.
> I'm doing it under linux with R 1.9.0 

Please update, as few of us have such an old system in use.

> (but hope to do it for windows too).
> I have trouble for loading my fortran code.

[...]

> I was thinking that my Geneland.so was loaded automatically
> by the command library("Geneland")

`Thinking'?  `Hoping', perhaps, but where did you read that?

> Obviously, it's not.
> Where and how should the library loaded ?

By your R code, via library.dynam.  A common `spell' is for package foo to 
include in foo/src/zzz.R

.First.lib <- function(libpath, pkgname)  
    library.dynam("foo", pkgname, libpath)

and it described in `Writing R Extensions'.  That also explains the 
different rules for packages with namespaces.

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