Skip to content

Optimising timeboxing in xts

2 messages · Hasan Diwan, R. Michael Weylandt

#
I don't know if timeboxing is the correct term to use to accomplish
what I'm attempting, so allow me to explain. I have a set n of tagged
observations in time series t. What I'm interested in is taking i
seconds before and after every n. My code is below:
# observations.xts is an xts time series and arg is the number of
seconds to for the timebox
timeboxes <- sapply(c(1:as.numeric(last(index(observations.xts))-arg)),
function(x) { return(observations.xts[index(x) - arg, index(x)+arg])},
simplify=TRUE)
What I'd like to see in timeboxes is observations.xts elements with
timestamps within the range of abs(arg).
4 days later
#
I might try something like this, untested: (I think you can do a
vector of arguments to `[.xts` but I'm not in a position to verify)

# let n be the times you want
# i be the width of the intervals

x[paste(n - i, n + i, sep = "::")]

Hope this helps,

Michael
On Fri, Dec 23, 2011 at 11:55 PM, Hasan Diwan <hasan.diwan at gmail.com> wrote: