I want to split xts/zoo
time-series in R
on weekly basis. The timezone is set to "Asia/Kolkata"
Sys.setenv(TZ="Asia/Kolkata")
library(xts)
seqs<- seq(as.POSIXct("2016-01-01"),as.POSIXct("2016-01-30"), by = "30 mins")
ob<- xts(data.frame(value=1:(length(seqs))),seqs)
weekdata <- split(ob,f="weeks",k=1)
The problem with this split
is that each week data is offset by 5:30 hours as shown below
> head(weekdata[[2]],2)
value
2016-01-04 05:30:00 156
2016-01-04 06:00:00 157
> head(weekdata[[3]],2)
value
2016-01-11 05:30:00 492
2016-01-11 06:00:00 493
I know it is due to timezone (5:30 hours for Asia/Kolkata). I also believe that this can be tuned by using endpoints
function, but I find it diffcult to fix. Can anyone provide some pointers?