jknowles / merTools

Convenience functions for working with merMod objects from lme4
104 stars 15 forks source link

Else condition needed for future.apply check #126

Closed kendavidn closed 1 year ago

kendavidn commented 1 year ago

Thanks for the fantastic package!

I may be wrong but it seems that there is a problem with this code, which is used in the lmerModList() family of functions:

if(parallel) {
    if (requireNamespace("future.apply", quietly=TRUE)) {
      ml <- future.apply::future_lapply(data, function(d) blmer(formula, data = d, ...))
    }
    warning("Parallel set but future.apply not available. Running sequentially.")
    ml <- lapply(data, function(d) blmer(formula, data = d, ...))
  }

If the future function is available, the line ml <- future.apply... will be run BUT the warning() line and the line after that will ALSO be run.

So whether or not future.apply is available, the warning will still be printed, and the regular lapply line will still run.

An else would solve this I think.

jknowles commented 1 year ago

Thanks that is right!