rdatextsweekday

Obtaining last Friday's date


I can get today's date:

Sys.Date( )

But how do I get last Friday's date?

I tried:

library(xts)

date1 <- Sys.Date( ) 
to.weekly(date1 )

But this gives an error.


Solution

  • I think this should work:

    library(lubridate)
    
    Sys.Date() - wday(Sys.Date() + 1)