[R] system.file(...) self-referencing the containing package

Murat Tasan mmuurr at gmail.com
Fri Dec 4 02:28:58 CET 2015

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?



More information about the R-help mailing list