From marc_schwartz at me.com  Wed Aug 17 14:35:41 2011
From: marc_schwartz at me.com (Marc Schwartz)
Date: Wed, 17 Aug 2011 07:35:41 -0500
Subject: [Rd] Referencing 'inst' directory in installed package
In-Reply-To: <A6A6DD95-ED16-4651-8902-76FB34C437C3@gmail.com>
References: <A6A6DD95-ED16-4651-8902-76FB34C437C3@gmail.com>
Message-ID: <7C2452FB-FF87-42F4-BD13-D8A23C36C600@me.com>

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



[Rd] Referencing 'inst' directory in installed package
Marc Schwartz