Extract first Monday of every month

后端 未结 3 1350
无人及你
无人及你 2021-01-13 14:17

How can I extract the first Monday of every month from 2010-01-01 to 2015-12-31?

3条回答
  •  感情败类
    2021-01-13 14:25

    Another apprach: using the Boost Date_Time library:

    library(RcppBDT)
    dates <- seq(as.Date("2010-01-01"), as.Date("2015-12-31"), by="1 month")
    do.call(c, lapply(dates-1, getFirstDayOfWeekAfter, dow=Mon))
    # [1] "2010-01-04" "2010-02-01" "2010-03-01" "2010-04-05" "2010-05-03"...
    

提交回复
热议问题