Skip to content
Prev 302048 / 398503 Next

Foreach help!

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: