[R] Optimising timeboxing in xts

R. Michael Weylandt michael.weylandt at gmail.com
Wed Dec 28 17:06:06 CET 2011


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:
> 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).
> --
> Sent from my mobile device
> Envoyait de mon portable
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list