Re: [Rd] Sections 5.8.1 and 5.8.2 of Writing R Extensions (LinkingTo)

From: Simon Urbanek <>
Date: Wed, 27 Oct 2010 14:43:01 -0400

On Oct 27, 2010, at 1:22 PM, Dominick Samperi wrote:

> Hello,
> In Sections 5.8.1 and 5.8.2 of Writing R Extensions the following pattern is
> suggested
> for getting the path to a file in another package:
> PKGB_PATH=Śecho ‚library(packB); cat(system.file("libs", package="packB"))‚
> \
> | ${R_HOME}/bin/R --vanilla --slaveŚ
> Is the library(packB) really needed here?

Not that I'm aware of - it's just a check that that package can be used. If you omit it you will get an empty string and no error on failure.

> It is not needed on two systems
> that
> I have tested: Windows and Linux. What about MacOS?
> If loading packB requires loading many other packages or doing expensive
> initialization it would be much more efficient if we could omit
> library(packB)
> here.
> On the other hand, keeping library(packB) has one possible advantage,
> namely,
> it may eliminate the need to add packB.dll to the loader's search path.

Not really since that sub-process will die when finished so it won't have any effect on any search path.

BTW: system.file("libs",...) doesn't do the job these days since it will be missing R_ARCH so you need something like system.file("libs",.Platform$r_arch, package=...) for any more recent R.


> So
> there
> is a trade-off of convenience vs efficiency.
> Thanks,
> Dominick
> [[alternative HTML version deleted]]
> ______________________________________________
> mailing list
> mailing list Received on Wed 27 Oct 2010 - 18:47:38 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 Wed 27 Oct 2010 - 20:00:14 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive