[Rd] useDynLib

Gabor Grothendieck ggrothendieck at gmail.com
Sun Jul 6 14:36:32 CEST 2014


I would like to be able to load two versions of a package at once and
to do that was thinking of giving each version a different package
name in the DESCRIPTION file and the building and installing each such
version separately.

library(myPkg1)
library(myPkg2)

and then use myPkg1::myFun() and myPkg2::myFun().

To do that easily it would be convenient if one could change the
package name in only one place (the DESCRIPTION file) and have that
propagate to all other uses of the package name in the package.

Suppose the package were named "myPkg".  Then the problem areas are:

1. The NAMESPACE file has myPkg hard-coded like this:

useDynLib(myPkg, .registration=TRUE)

2. The configure.ac file has myPkg hard-coded like this:

AC_INIT([myPkg], 1.0.0)

3. There are various references to myPkg hard-code throughout the R
code, e.g. myPkg::myFun, but I am ok here as I assume this would work
where an .onLoad would be used to grab the package name from the
.onLoad's pkgname argument:
   `::`(pkgname, MyFun)
(Also some or all of these may not be needed in the first place.)

1. Is there some way to cause these instances to change when the
package name in the DESCRIPTION file changes or is there some other
approach that would make it easy to change the package name in just
one spot or some other way to load two packages that are versions of
each other at one time.  (The fact that the package has C++ code seems
to be the complicating factor.)

2. Are there any examples of CRAN packages that have been set up to
make this easy to do?

Thanks.

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com



More information about the R-devel mailing list