Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

parallel R execution problem in R

I am using doSMP as a parallel backend in Windows 7, with R 2.12.2. I incur in an error, and would like to understand the likely cause. Here is some sample code to reproduce the error.

require(foreach)
require(doSMP)
require(data.table)
wrk <- startWorkers(workerCount = 2)
registerDoSMP(wrk)
DF = data.table(x=c("b","b","b","a","a"),v=rnorm(5))
setkey(DF,x)
foreach( i=1:2)  %dopar% {
    DF[J("a"),]
}

The error message is

Error in { : task 1 failed - "could not find function "J""
like image 571
gappy Avatar asked Apr 01 '11 12:04

gappy


1 Answers

I've not used doSMP, but I did some digging around and it looks like this post gets at a similar issue.

so it looks like you should be able to do:

foreach( i=1:2, .packages="data.table")  %dopar% {
    DF[J("a"),]
}

I can't test as I don't have a Windows machine handy.

like image 180
JD Long Avatar answered Sep 23 '22 23:09

JD Long