On Aug 16, 2011, at 10:17 PM, Jonathan Malmaud wrote:

> Hi,
> My R package has files in the 'inst' directory that it needs to reference. 
> How can the R scripts in my package find out the full path to the 'inst' 
> directory after the package is installed, given that different users may have 
> installed the package to different libraries? 
> 
> Thanks,
> Jon Malmaud


See ?path.package and ?file.path

Example:

> require(WriteXLS)
Loading required package: WriteXLS

# I am on OSX
> path.package("WriteXLS")
[1] "/Library/Frameworks/R.framework/Versions/2.13/Resources/library/WriteXLS"

I have Perl scripts in my package, which are in the /inst/Perl folder in the 
package source, so:

> file.path(path.package("WriteXLS"), "Perl/WriteXLS.pl")
[1] 
"/Library/Frameworks/R.framework/Versions/2.13/Resources/library/WriteXLS/Perl/WriteXLS.pl"


HTH,

Marc Schwartz

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to