Try the following:
library(zoo) lastfri(Sys.Date())
where lastfri matches the function of the nextfri single line in this zoo vignette, zoo quickref vignette , except that ceiling is replaced with floor . Note that lastfri vectorized, that is, it can take a vector of input dates and output a vector of output dates. For instance,
library(zoo) Sys.Date() ## 2015-03-10 lastfri(Sys.Date() + 0:6) ## [1] "2015-03-06" "2015-03-06" "2015-03-06" "2015-03-13" "2015-03-13" ## [6] "2015-03-13" "2015-03-13"
Thus, last Friday was March 6th, and we continue to receive March 6th until the day reaches next Friday, at this moment last Friday is March 13th.
In addition: next Friday - Friday the 13th.
source share