[R-SIG-Finance] Aggregating irregular time series

R_help Help rhelpacc at gmail.com
Mon Aug 31 03:38:44 CEST 2009


Hi,

I have a couple of aggregation operations that I don't know how to
accomplish. Let me give an example. I have the following irregular
time series

time                              x
10:00:00.021                20
10:00:00.224                20
10:00:01.002                19
10:00:02:948                20

1) For each entry time, I'd like to get sum of x for the next 2
seconds (excluding itself). Using the above example, the output should
be

time                        sumx
10:00:00.021                39
10:00:00.224                19
10:00:01.442                20
10:00:02:948                 0

2) For each i-th of x in the series, what's the first passage time to
x[i]-1. I.e. the output should be

time                           firstPassgeTime
10:00:00.021                0.981
10:00:00.224                0.778
10:00:01.442                NA
10:00:02:948                NA

Is there any shortcut function that allows me to do the above? Thank you.

adschai



More information about the R-SIG-Finance mailing list