library(lubridate)
dates <- seq(Sys.Date() - 100, Sys.Date(), by = "1 days")
week.ids <- floor_date(dates, "week")
Now dates
will have each of the last 100 days, and week.ids
will have the date of the most recent Sunday before each of the dates in dates
. Therefore, the week.ids
vector provides the sufficient information to group the dates by week.