[R] dopar parallel assignments

Vivek Ayer vivek.ayer at gmail.com
Thu Apr 29 23:07:39 CEST 2010


Hi guys,

I was wondering why this piece of code doesn't work:

foreach (i = c(1.25,1.50)) %dopar% {
assign(paste("test_",i,sep=""),i)
}

but, this does:

foreach (i = c(1.25,1.50)) %do% {
assign(paste("test_",i,sep=""),i)
}

Obviously, the difference is %dopar% vs. %do%. If I use %do%, I get
objects test_1.25 and test_1.50, but I don't get these objects if I
use %dopar% even though it seemed to run through the loop in parallel.

Thanks in advance,
Vivek



More information about the R-help mailing list