Get Dates of a Certain Weekday from a Year in R

前端 未结 3 1622
借酒劲吻你
借酒劲吻你 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 22:48

    I found seq.Date which is part of base. Not sure if there are caveats to this method but it seems to do what I want:

    x = seq(as.Date("2012/01/02"), as.Date("2013/01/01"), "7 days")
    as.POSIXct(x)
    

提交回复
热议问题