I am using intra-day data that starts at 9:50am and would like to convert it into 20 minute time intervals so the first period would be from 09:50 to 10:09:59 and the second time period would be from 10:10 to 10:29:59 etc. However to.minutes()
from the xts
package seems to fix it onto the hours and the has time bars at 09:59:59 and 10:19:59 etc...i.e. it is 10 minutes out... i know its probably not a regular request...but is there anyway of doing this so that it has the correct endpoints, i.e. basing it upon the frist timestamp?
and for bonus points...is there a way to do do it based on the final time stamp? (i.e. generateing the period endpoints going backwards from that timestamp?
here is an illustration of my point about it being 10 minutes out (from what I want)
x <- xts(rnorm(24*60*60), as.POSIXct(format(paste(Sys.Date(),'09:50')))-((24*60*60):1))
head(x)
x1 <- to.minutes(x, 20)
head(x1)
I can think of a way to correct this by using splits, cuts, lapplys do.calls and rbinds....but I would basically be re-creating an OHLC object...and feel that it might be inefficient in comparison to existing solutions...