I am trying to use doRedis to create an R cluster and parallel process some of my calculations with foreach, but keep running into errors. My code works with foreach %do% but when I try to run on the cluster with %dopar% it fails. I also tried running the example code in the doRedis docs which fails as well. Below is the R console of my main script and a worker:
The main R console:
> require('doRedis')
> registerDoRedis('work')
> getDoParWorkers()
[1] 2
> foreach(j=1:10,.combine=sum,.multicombine=TRUE) %dopar%
+ 4*sum((runif(1000000)^2 + runif(1000000)^2)<1)/10000000
[1] "interrupt: \n"
Error in tryCatchOne(expr, names, parentenv, handlers[[1L]]) :
attempt to apply non-function
In addition: Warning message:
In e$fun(obj, substitute(ex), parent.frame(), e$data) :
Queue length off by 10...correcting
The worker console:
> require('doRedis')
> redisWorker('work')
Waiting for doRedis jobs.
Processing job 3 from queue work
Error in names(z) <- w[o] :
'names' attribute [69] must be the same length as the vector [68]
I am not sure what is causing the errors but it seems like everything I send to the worker results in this error:
`Error in names(z) <- w[o] :
'names' attribute [69] must be the same length as the vector [68]`
Anyone have any ideas how to fix this?