I want to divide the daily xts object into 4 weeks, which correspond to the following days of the month: 1st, 8th-14th, 15th-21st and 22nd until the end of the month, where last week usually longer (but that's fine!).
Here is an example code for the xts object code for January 2004, created from a sequence of dates:
week <- seq(from=as.Date("2004-01-01"), to=as.Date("2004-01-31"), by = "day") x2 <- sample(1:50, 31)
The problem is that January 1 does not happen on Sunday, so split.xts does not necessarily do what I want.
Initially, I thought that I could create four intervals corresponding to the days noted above, however I do not know if this is correct.
Is there a way to break an xts object into the intervals you create?
source share