Closed grabear closed 5 years ago
What's your overall vision for this? To just include our data in the package?
No, I just wanted a way to access "private variables". So that they can be used in our functions without being accessible outside of our package.
pkg.env <- new.env(parent = emptyenv())
pkg.env$format_level_list <- list(unknown_format = -1, mixed_format = -1,
phyloseq_format = 0, raw_format = 1,
basic_format = 2, analyzed_format = 3)
format_table_list <- list(
raw_format = c("otu_abundance", "otu_annotations"),
basic_format = c(raw_names, "taxa_abundance", "otu_proportions", "taxa_proportions"),
analyzed_format = c(basic_names, "statistical_data", "stats_tax_data"),
phyloseq_format = c("otu_table", "tax_data", "sample_data", "phy_tree")
)
# etc. etc.
# and then
random_func <- function() {
print(pkg.env$format_table_list$analyzed_format)
}
Funny enough, I found myself looking for similar yesterday. I thought I'd read a while back about how to access private variables, but I've been drawing a blank on it.
I think the above method is a good workaround though.
Implemented with: 2869a438e82cadf342c2730b5a7d08358e9f324a
@grabear commented on Fri Dec 07 2018
Our current way of doing this is using a function and adding the data to the global environment with:
However a more elegant solution might be to create a "package environment" (link so that this data does not easily disrupt the end users experience.