It seems the Internet has not answered this question for R yet:
If I have a date. Say the 20th of march: as.Date(\"2015-03-20\") how do I get, in R, the previous Sun
One way:
d<-as.Date("2015-03-20") d-as.POSIXlt(d)$wday ## [1] "2015-03-15"
There;s also the more hackish way, using the fact that dates are represented as integers with day zero being a Thursday (Jan 1 1970):
d-((as.numeric(d)+4)%% 7) ## [1] "2015-03-15"