Hi, just during these vacation days, I'm trying to approach with multicore package and I have some troubles with foreach. ex. foreach(.combine=c, ii=1:200, jj=1:500) %dopar% makefunction[ii,jj] Command seem to work but if I see ii and jj value at the and of cycle, they are both 200 instead than ii=200 and jj=500. Why?? Can someone help me? Thank you in advance. Max -- View this message in context: http://r.789695.n4.nabble.com/Foreach-help-tp4638688.html Sent from the R help mailing list archive at Nabble.com.
Foreach help!
3 messages · Cloneberry, R. Michael Weylandt
I believe that foreach() only goes along the "shorter" of the iteration vectors. E.g., foreach(.combine = c, i = 1:10, j = 1:15) %do% print(i + j) stops when i == 10 (and j = 10 as well). To make it more explicit foreach(.combine = c, i = 1:10, j = 11:25) %do% print(i + j) stops when j = 20 because you run out of "i" foreach does not seem designed for exhaustive search -- you might need expand.grid() or some such if you want the cartesian product of ii and jj. Best, Michael
On Wed, Aug 1, 2012 at 9:09 AM, Cloneberry <cloneberry at gmail.com> wrote:
Hi, just during these vacation days, I'm trying to approach with multicore package and I have some troubles with foreach. ex. foreach(.combine=c, ii=1:200, jj=1:500) %dopar% makefunction[ii,jj] Command seem to work but if I see ii and jj value at the and of cycle, they are both 200 instead than ii=200 and jj=500. Why?? Can someone help me? Thank you in advance. Max -- View this message in context: http://r.789695.n4.nabble.com/Foreach-help-tp4638688.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.
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120802/3dce543f/attachment.pl>