[R-SIG-Finance] Aggregating time series to every 30sec

Robert A'gata rhelpacc at gmail.com
Fri May 6 02:47:31 CEST 2011


Hi,

I have an irregular return time series that looks like below:

> head(r.xts)
                             [,1]
2011-05-05 09:30:04.929 0.3264757
2011-05-05 09:30:14.907 0.0934498
2011-05-05 09:30:19.917 0.8956367
2011-05-05 09:30:35.114 1.6632110
2011-05-05 09:30:45.193 1.1666715
2011-05-05 09:31:12.417 0.2861861

I'd like to sum them for every 30-second bucket such that the output
looks like below. The key is that I want to aggregate every 30 seconds
by clock time NOT 30 seconds starting from my first observation time
stamp. rollapply does not satisfy my objective as it takes number of
rows instead. to.period function doesn't seem to let me specify that I
want to start at 09:30 and sum returns every 30 seconds. I'm wondering
if there's any tool that I can achieve this?

2011-05-05 09:30:00   1.316
2011-05-05 09:30:30   ...
2011-05-05 09:31:00   ...

Thank you in advance.

Cheers,

Robert



More information about the R-SIG-Finance mailing list