Get Dates of a Certain Weekday from a Year in R

前端 未结 3 1620
借酒劲吻你
借酒劲吻你 2020-12-06 22:36

How might I generate a list of date objects (POSIXct or lt) for each Monday of a year?

For instance this year would be (In Year, Month, Day):

2012_01_02,
         


        
3条回答
  •  鱼传尺愫
    2020-12-06 23:12

    as.Date("2012_01_02", format="%Y_%m_%d") +seq(0,366,by=7)  # 2012 is a leap year.
    

    If you really want them as DateTimes with all the attendant hassles of timezones then you can coerce them with as.POSIXct.

提交回复
热议问题