[R] system.file(...) self-referencing the containing package
mmuurr at gmail.com
Fri Dec 4 17:28:51 CET 2015
(Any idea if/where this is documented? I checked through the "Writing
R Extensions" doc and couldn't find any mention of it.)
Thanks much again,
On Thu, Dec 3, 2015 at 6:42 PM, William Dunlap <wdunlap at tibco.com> wrote:
> Every package has in it, after it is installed, a character object
> called ".packageName" containing its name. It is not exported from
> the package. Functions in your package can refer to it as just
> Bill Dunlap
> TIBCO Software
> wdunlap tibco.com
> On Thu, Dec 3, 2015 at 5:28 PM, Murat Tasan <mmuurr at gmail.com> wrote:
>> In a package I'm writing, I'm placing all SQL code here:
>> And so when referring to these blocks of code from the package's R
>> code, I do something like so:
>> system.file("sql", "my_example_file.sql", package = "ThisPackage",
>> mustWork = TRUE)
>> But, referring to the package itself with the string "ThisPackage" is
>> annoying and somewhat brittle... if the package were ever to change
>> names (e.g. during development), I'll have to replace all such calls
>> with the new package name.
>> And generally referring to the package containing the code itself by
>> name seems inelegant.
>> Anyone know of a safe way to reference additional files in a package,
>> from within that package's code, that doesn't require specifying the
>> name of the package as a string?
>> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help