[Bioc-devel] helper function arguments: best practice

Severin Bang @ever|n@b@ng @end|ng |rom phy@|k@un|-|re|burg@de
Fri Apr 16 13:14:32 CEST 2021

Dear community,

I am writing my first package with the aim to publish it on 
Bioconductor. To structure the code and make it  (human) readable I have 
defined some helper functions, that will not be exported.

The main function (which will be user available) makes some data 
structuring, defines some variables and will then call a helper function 
in a lapply-call on a list of data.frames.

Now I find myself passing >>10 arguments (basically everything that was 
defined in the main function before the lapply call) to the helper 
function when executed by lapply. All arguments (except the index of the 
current data.frame from the list which is lapplyd over) are static for 
all the runs.

My question is now: What is considered best practice in this case? 
should I put all parameters in a list? Is there a way to pass the whole 
"parent" environment (the locale of the main function) to lapply, or 
should I keep all the single parameters?

Maybe a "pseudo code" example is useful; this is how my problem is 

main_function <- function(alot, of, paramters) {
   var01 <- foo
   varXX <- bar
   data_list <- list(data01, data02, data03, ... , dataYY)

     ) {
       helper_function(var01, ... , varXX)
     var01 = var01,
     varXX = varXX

Thank you very much!


More information about the Bioc-devel mailing list