I have created a function DevCstat().
It takes the arguments: indat, mod, Covar,txtMat, PatCovar.
indat is a list, I would like to apply the function to each element of the list.
mod, Covar, txtMat, PatCovar, are objects that I would like to use for each call to the function, these do not change over the list elements.
This seems to work:
lapply(test, DevCstat, mod='A', Covar=Covar,txtMat=txtMat, PatCovar=PatCovar)
However, the parallel version does not work:
mclapply(test,DevCstat,mod = 'A', Covar=Covar, txtMat=txtMat, PatCovar=PatCovar, SIMPLIFY = F, mc.cores = getOption("mc.cores", numcore))
I get the error
all scheduled cores encountered errors in the user code
I think the problem is that mclapply is not passing the additional arguments.
Does anyone know how to correctly do this?
Thanks