Skip to content
Back to formatted view

Raw Message

Message-ID: <ad1ead5f0908301838g3a64adf1rc66df7b36c3fbdc0@mail.gmail.com>
Date: 2009-08-31T01:38:44Z
From: R_help Help
Subject: Aggregating irregular time series

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