Skip to content
Prev 17863 / 21312 Next

[Bioc-devel] Methods to speed up R CMD Check

Doesn't really matter where you put them but 
.my_internal_global_variables, .get_eh(), .set_eh(), and toto() don't 
need to be defined inside the .onLoad() hook, and it's actually 
cleaner/easier to not define them there. You can define there anywhere 
in your ewceData/R/* files.

Here is a slightly improved version of the code:

   .my_internal_global_variables <- new.env(parent=emptyenv())

   .get_eh <- function() get("eh", envir=.my_internal_global_variables)
   .set_eh <- function(value) assign("eh", value, 
envir=.my_internal_global_variables)

   get_ExperimentHub <- function()
   {
     eh <- try(.get_eh(), silent=TRUE)
     if (inherits(eh, "try-error")) {
       eh <- ExperimentHub::ExperimentHub()
       .set_eh(eh)
     }
     eh
   }

In my packages I like to put this kind of low-level stuff in R/utils.R. 
None of this is exported.

Then anywhere in your package when you need an ExperimentHub instance, do:

   ## Exported.
   tt_alzh <- function()
   {
     eh <- get_ExperimentHub()
     eh[["EH5373"]]
   }

H.
On 3/23/21 10:53 AM, Murphy, Alan E wrote: