[R] Parallel for that does not keep the results

Alaios alaios at yahoo.com
Tue Feb 24 15:52:40 CET 2015


Hi all,I am working in a multi core machine and I am trying to make some parallel code to speed up the process.
I have seen already the foreach packet but it looks like that it always combine the results on a list. My case though is simpler since I am plotting and saving in external files, inside the loop, and thus I do not need to keep anything from the loop.My code looks like
    expandMeanSigmaOn<-expand.grid(1:100,100:200,5:10,5000:6000)
   for (i in 1:length(expandMeanSigmaOn$Var1)){
                                        mean1<-expandMeanSigmaOn$Var1[i]
                                        mean2<-expandMeanSigmaOn$Var2[i]
                                        sd1<-expandMeanSigmaOn$Var3[i]
                                        sd2<-expandMeanSigmaOn$Var4[i]
                                   
                                            fitcass1<-mix(mydata,mixparam(c(mean1,mean2),(c(sd1,sd2)),"gamma")))
                                            pdf(file=paste(filename,"ON.pdf",sep=""));plot(fitcass1);dev.off() # plotting and saving
                                            save(OnFitList,file=paste(filename,"ON.Rdata",sep="")) # plotting and saving
                                            }
                                        }
 }

as you can see from the code above, given some input values I am trying some fits, which then I am saving the results. Do you think that the foreach packaget would be suitable (since the returning list can grow very large and eat up memory) or should I try some alternative package?
I would like to thank you in advance for your replyRegardsAlex

	[[alternative HTML version deleted]]



More information about the R-help mailing list