1method <- Sys.getenv("FOREACH_BACKEND", "SEQ") 2 3if(method == "PAR") { 4 cl <- parallel::makeCluster(2, type="PSOCK") 5 .Last <- function() { 6 parallel::stopCluster(cl) 7 } 8 doParallel::registerDoParallel(cl) 9} else if(method == 'MC') { 10 doMC::registerDoMC() 11} else if(method == 'SEQ') { 12 registerDoSEQ() 13} else { 14 stop('illegal backend specified: ', method) 15} 16 17