diff --git a/pkg/BayesFactor/DESCRIPTION b/pkg/BayesFactor/DESCRIPTION index 3e408e0..0315496 100644 --- a/pkg/BayesFactor/DESCRIPTION +++ b/pkg/BayesFactor/DESCRIPTION @@ -10,7 +10,7 @@ License: GPL-2 VignetteBuilder: knitr Depends: R (>= 3.0.0), coda, methods Imports: pbapply, mvtnorm, stringr, utils, graphics -Suggests: doMC, testthat, knitr, markdown, arm, lme4, xtable, languageR +Suggests: doMC, foreach, testthat, knitr, markdown, arm, lme4, xtable, languageR URL: http://bayesfactorpcl.r-forge.r-project.org/ BugReports: https://github.com/richarddmorey/BayesFactor/issues LazyLoad: yes diff --git a/pkg/BayesFactor/R/anovaBF.R b/pkg/BayesFactor/R/anovaBF.R index cf11425..6518cf5 100644 --- a/pkg/BayesFactor/R/anovaBF.R +++ b/pkg/BayesFactor/R/anovaBF.R @@ -172,20 +172,22 @@ anovaBF <- } if(multicore){ - warning("Progress bars and callbacks are suppressed when running multicore.") - if(!require(doMC)){ + message("Progress bars and callbacks are suppressed when running multicore.") + if(!require(doMC, quietly = TRUE)){ stop("Required package (doMC) missing for multicore functionality.") } - registerDoMC() - if(getDoParWorkers()==1){ + doMC::registerDoMC() + if(foreach::getDoParWorkers()==1){ warning("Multicore specified, but only using 1 core. Set options(cores) to something >1.") } - bfs <- foreach(gIndex=models, .options.multicore=mcoptions) %dopar% + bfs <- foreach::"%dopar%"( + foreach::foreach(gIndex=models, .options.multicore=mcoptions), lmBF(gIndex,data = data, whichRandom = whichRandom, rscaleFixed = rscaleFixed, rscaleRandom = rscaleRandom, iterations = iterations, method=method,progress=FALSE,noSample=noSample) + ) }else{ # Single core diff --git a/pkg/BayesFactor/R/generalTestBF.R b/pkg/BayesFactor/R/generalTestBF.R index 2c2cb68..431f394 100644 --- a/pkg/BayesFactor/R/generalTestBF.R +++ b/pkg/BayesFactor/R/generalTestBF.R @@ -88,22 +88,23 @@ generalTestBF <- "options('BFMaxModels').") if(multicore){ - warning("Progress bars and callbacks are suppressed when running multicore.") - if(!require(doMC)){ + message("Progress bars and callbacks are suppressed when running multicore.") + if(!require(doMC, quietly = TRUE)){ stop("Required package (doMC) missing for multicore functionality.") } - registerDoMC() - if(getDoParWorkers()==1){ + doMC::registerDoMC() + if(foreach::getDoParWorkers()==1){ warning("Multicore specified, but only using 1 core. Set options(cores) to something >1.") } - bfs <- foreach(gIndex=models, .options.multicore=mcoptions) %dopar% + bfs <- foreach::"%dopar%"( + foreach::foreach(gIndex=models, .options.multicore=mcoptions), lmBF(gIndex,data = data, whichRandom = whichRandom, rscaleFixed = rscaleFixed, rscaleRandom = rscaleRandom, rscaleCont = rscaleCont, iterations = iterations, method=method, progress=FALSE,noSample=noSample) - + ) }else{ # Single core bfs = NULL