actulab-2014-solution-coope.../mcsapply.R
François Pelletier fe69dd920d Update mcsapply.R
change from multicore to parallel requirement as multicore is deprecated
2014-08-08 13:38:52 -04:00

12 lines
368 B
R

require("parallel")
mcsapply <- function (X, FUN, ..., simplify = TRUE, USE.NAMES = TRUE)
{
FUN <- match.fun(FUN)
answer <- mclapply(X = X, FUN = FUN, ...)
if (USE.NAMES && is.character(X) && is.null(names(answer)))
names(answer) <- X
if (!identical(simplify, FALSE) && length(answer))
simplify2array(answer, higher = (simplify == "array"))
else answer
}