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@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel