[R] foreach not recognizing functions in memory
Bos, Roger
roger.bos at rothschild.com
Wed Jul 13 22:14:18 CEST 2011
Saskay,
Thanks so much for that example. It worked fine on my system. I didn't
realized SNOW worked on windows. I will have to read more about it.
Thanks again,
Roger
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of saskay
Sent: Wednesday, July 13, 2011 2:59 PM
To: r-help at r-project.org
Subject: Re: [R] foreach not recognizing functions in memory
Try the below code:
==============================
library(foreach)
library(doSNOW)
getDoParWorkers()
getDoParName()
registerDoSNOW(makeCluster(2, type = "SOCK"))
getDoParWorkers()
getDoParName()
testFun <- function(m) {
out <- m*m
}
out <- foreach(m=1:10, .combine=rbind,*.verbose=T*) %dopar% testFun(m)
helper <- function(i) {
out <- foreach(m=1:i, .combine=rbind,*.export="testFun", .verbose=T*)
%dopar% testFun(m) }
out <- helper(10)
--
View this message in context:
http://r.789695.n4.nabble.com/foreach-not-recognizing-functions-in-memor
y-tp3663603p3665806.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
***************************************************************
This message is for the named person's use only. It may\...{{dropped:20}}
More information about the R-help
mailing list