From simon.urbanek at r-project.org  Wed Oct 27 20:43:01 2010
From: simon.urbanek at r-project.org (Simon Urbanek)
Date: Wed, 27 Oct 2010 14:43:01 -0400
Subject: [Rd] Sections 5.8.1 and 5.8.2 of Writing R Extensions
	(LinkingTo)
In-Reply-To: <AANLkTikcv4Pi5G4pcSn=Z6ie9gjgXeBBR7Kie78wOZaC@mail.gmail.com>
References: <AANLkTikcv4Pi5G4pcSn=Z6ie9gjgXeBBR7Kie78wOZaC@mail.gmail.com>
Message-ID: <BC213552-F93E-4C22-939D-81F085F920D5@r-project.org>


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.

Cheers,
Simon


> So
> there
> is a trade-off of convenience vs efficiency.
> 
> Thanks,
> Dominick
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Sections 5.8.1 and 5.8.2 of Writing R Extensions (LinkingTo)
Simon Urbanek