[R] Foreach help!
R. Michael Weylandt
michael.weylandt at gmail.com
Thu Aug 2 01:20:25 CEST 2012
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.
More information about the R-help
mailing list