Skip to content

parallel processing with foreach

2 messages · pxs101220, Peter Langfelder

#
Hi,

I am trying to  parallel computing with foreach function, but not able to
get the result. I know that in parallel processing, all result is collected
in list format, but I am not able to get input there.
Any help is really appreciated.


esf.m <-foreach (i = 1:n.s, .combine=rbind) %dopar%  {
  EV <- as.data.frame(eig$vectors[,1:n.candid[i]])
  colnames(EV) <- paste("EV", 1:NCOL(EV), sep="")

  r25.esf.f <- lm(y ~ x1 + x2 +., data = EV)
  assign(paste("r25.esf.", i, sep=""), stepwise.forward(r25.esf.f, lm(y ~ x1
+ x2, data = EV), 0.1, verbose = F))}



--
View this message in context: http://r.789695.n4.nabble.com/parallel-processing-with-foreach-tp4647381.html
Sent from the R help mailing list archive at Nabble.com.
#
It seems you don't quite understand how foreach works. foreach (..)
%dopar% { ... } takes the last value from each of the second {...}
evaluations and feeds them to the .combine function (in your case
rbind()). Since your last call in the %dopar% {...} block is assign(),
you are not getting anything meaningful.

Make the last value a vector that you want to be "rbind-ed" to the result.

HTH,

Peter
On Thu, Oct 25, 2012 at 1:47 AM, pxs101220 <pxs101220 at utdallas.edu> wrote: