[R-pkg-devel] referring to a package data object by two names
Berry Boessenkool
berryboessenkool at hotmail.com
Mon Oct 9 14:36:51 CEST 2017
Another approach, maybe overkill / not thought through:
latestLandmark <- function()
{
files <- dir(file.path(system.file(package="yourpackage"), "data"),
pattern="landmark", full.names=TRUE)
env <- environment()
dataset <- load(tail(files, 1), envir=env)
return(invisible(get(dataset, envir=env)))
}
landmark <- latestLandmark()
Regards,
Berry
________________________________
From: R-package-devel <r-package-devel-bounces at r-project.org> on behalf of Gregory Jefferis <jefferis at gmail.com>
Sent: Sunday, October 8, 2017 14:45
To: Michael Dewey
Cc: r-package-devel at r-project.org
Subject: Re: [R-pkg-devel] referring to a package data object by two names
Dear Michael,
Many thanks for writing.
> Do any of the suggestions in section 1.5.3 of Writing R Extensions "Load hooks" work?
I thought I had tried all the various permutations in .onLoad but at your prompting I tried some more and this seems to work:
.onLoad <- function (libname, pkgname) {
# set up default landmarks object
assign('landmarks',
envir = parent.env(environment()),
testdataalias::landmarks.2017)
}
It doesn't seem to tickle R CMD check, but I'm not yet convinced that it is[[elided Hotmail spam]]
Best wishes,
Greg.
______________________________________________
R-package-devel at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel
[[alternative HTML version deleted]]
More information about the R-package-devel
mailing list