[R] foreach question

Santosh Srinivas santosh.srinivas at gmail.com
Sun Dec 5 15:49:09 CET 2010


Hello Group,

I am experimenting with parallel processing ... here is part of my code.

require(snow)
require(doSNOW)
require(foreach)
cl.tmp = makeCluster(rep("localhost",4), type="SOCK")
registerDoSNOW(cl.tmp)
	
foreach(i=1:NROW(sDat),.packages="gdata",.verbose=TRUE) %dopar% {

do something 1
do something 2
do something 3
}

I ran this individually without a parallel setup and it works perfectly

Now when I do the parallel invocation the error being thrown is that
the functions which I created are not being passed to the parallel
instances.
do something 1,2,3 above use my functions which I created in the code itself.

Is there someway that I can have then pass to the parallel routines?
Is this the right approach?

Thanks and have a nice weekend.
S



More information about the R-help mailing list