List comprehension of 2+ variables in R
<p>What's the best R equivalent of the Python 2-variable list comprehension</p>

<pre><code>[datetime(y,m,15) for y in xrange(2000,2020) for m in [3,6,9,12]]
</code></pre>

<p>The result</p>

<pre><code>[datetime.datetime(2000, 3, 15, 0, 0), 
datetime.datetime(2000, 6, 15, 0, 0), 
datetime.datetime(2000, 9, 15, 0, 0),
datetime.datetime(2000, 12, 15, 0, 0), 
datetime.datetime(2001, 3, 15, 0, 0) ... ]
</code></pre>

<p>This will produce equivalent results in R</p>

<pre><code>with(expand.grid(m=c(3,6,9,12), y=2000:2020), ISOdate(y,m,15))
</code></pre>

<p>We use <code>expand.grid</code> to get all combinations of year and month, and then we just use the vectorized <code>ISOdate</code> function to get the values.</p>

python