python - List comprehension of 2+ variables in R -
what's best r equivalent of python 2-variable list comprehension
[datetime(y,m,15) y in xrange(2000,2020) m in [3,6,9,12]]
the result
[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) ... ]
this produce equivalent results in r
with(expand.grid(m=c(3,6,9,12), y=2000:2020), isodate(y,m,15))
we use expand.grid
combinations of year , month, , use vectorized isodate
function values.
Comments
Post a Comment