How to figure third Friday of a month in R

后端 未结 4 1450
日久生厌
日久生厌 2020-12-06 15:36

I\'m trying to figure out of how to create a vector of dates of third Fridays of a month for the past 3 years

Thank you in Advance

4条回答
  •  天命终不由人
    2020-12-06 16:28

    Alternative base solution giving the same result using @jbaums' data again:

    d <- seq(as.Date("2000/1/1"), by = 1, length.out = 500)
    d <- as.POSIXlt(d)
    d <- d[d$wday==5]
    as.Date(d[ave(d$mon,list(d$mon,d$year),FUN=seq_along)==3])
    

提交回复
热议问题