[R] generate irregular series of dates

Gabor Grothendieck ggrothendieck at gmail.com
Tue Jun 29 21:21:48 CEST 2010

On Tue, Jun 29, 2010 at 6:22 AM, Simon Kiss <sjkiss at gmail.com> wrote:
> Dear colleagues, particularly academic ones,
> So I'm creating a Microsoft Word template for myself so that every time I
> teach a new course, I don't have to enter in the dates manually for each
> class session.
> I'd like to use an R script that can generate an irregular series of dates
> starting from one date (semester begin) to another (semester end) using an
> irregular interval in between (Tuesdays and Thursdays, for example).
> I know that a regular series of dates is no problem, but what about an
> irregular series?

Generate all the dates in the range of interest and then pick off the
Tuesdays and Thursdays:

dd <- seq(as.Date("2010-01-01"), as.Date("2010-12-31"), "day")
dd[weekdays(dd) %in% c("Tuesday", "Thursday")]

More information about the R-help mailing list