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 structured:

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

  lapply(
    seq_along(data_list),
    function(
      i,
      var01,
      ...
      varXX
    ) {
      stuff
      helper_function(var01, ... , varXX)
    },
    var01 = var01,
    ...
    varXX = varXX
  )
}


Thank you very much!

Best,
Severin

_______________________________________________
Bioc-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/bioc-devel

Reply via email to