A variant (not quite as good because parent = emptyenv() is not an argument) is
pkg_data <- local({ a = 1; b =2; environment() })
If information at load time is also important, one might add
.onLoad <- function(libname, pkgname) {
pkg_data[["last_update"]] <- Sys.time()
}
which is actually
Thank you!
I had actually tried that, but forgot to export that additional R script.
This makes sense.
On January 29, 2019 at 16:47:20, Gábor Csárdi (csardi.ga...@gmail.com)
wrote:
You don't need .onLoad for this, just put the environment into the
package environment. E.g. simply add
pkg_data <
You don't need .onLoad for this, just put the environment into the
package environment. E.g. simply add
pkg_data <- new.env(parent = emptyenv())
to your package code. Then you can refer to pkg_data from the
functions in the package.
Best,
Gabor
On Tue, Jan 29, 2019 at 9:40 PM Pascal Title wrot
Hi,
I am developing an R package where I would like to have a set of names
defined once, and which could then be queried from within the various
functions of the package. The way I have currently set this up is to define
a new environment that contains these names.
So, what I currently have is: