Thank you Michael,
I thought from the beginning that the explanation was something similar.
Now, I try with expand.grid. Just for information, from another forum, I
received the following explanation:*
*

*Louis Schenck<http://www.linkedin.com/groups?viewMemberFeed=&gid=2229532&memberID=13075768>•
You can find the answer in the foreach vignettes on page 3:
http://cran.r-project.org/web/packages/foreach/vignettes/foreach.pdf<http://www.linkedin.com/redirect?url=http%3A%2F%2Fcran%2Er-project%2Eorg%2Fweb%2Fpackages%2Fforeach%2Fvignettes%2Fforeach%2Epdf&urlhash=2uk-&_t=tracking_disc>
In your case both ii and jj are iteration variables. They both iterate at
the same time. So the length will be only as long as the shortest
iteration. If you are trying to nest loop you will need the %:% operator.
It might look something like:
foreach(jj=1:2) %:% foreach( ii=12:11) %do% {c(ii,jj)} *
Best,
Max




On Thu, Aug 2, 2012 at 1:25 AM, Michael Weylandt [via R] <
ml-node+s789695n4638803h2@n4.nabble.com> wrote:

> 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 <[hidden email]<http://user/SendEmail.jtp?type=node&node=4638803&i=0>>
> 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.
> >
> > ______________________________________________
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=4638803&i=1>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.
>
> ______________________________________________
> [hidden email] <http://user/SendEmail.jtp?type=node&node=4638803&i=2>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.
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
> http://r.789695.n4.nabble.com/Foreach-help-tp4638688p4638803.html
>  To unsubscribe from Foreach help!, click here<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=4638688&code=Y2xvbmViZXJyeUBnbWFpbC5jb218NDYzODY4OHwtMTI2ODQwODg0Ng==>
> .
> NAML<http://r.789695.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://r.789695.n4.nabble.com/Foreach-help-tp4638688p4638834.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]

