[R] Extracting maximums from a sliding window

Jamie Ledingham jamie.ledingham at newcastle.ac.uk
Tue Mar 25 11:08:32 CET 2008


Dear all, I am having some problems with the folowing task and would
appreciate any thoughts on the matter.

I have a sliding window time series of rainfall.  This is 24 hour window
created from an hourly record.  Every hour, a new twenty four hour total
is calculated.  I would like to extract the Top 50 twenty four hour
totals however I have a problem.

Simply ranking the sliding window time series and pulling off the top 50
totals leaves me with many overlapping periods as seen below.  The
column on the right is rainfall amount, to the left of that are the
indices showing the 24 hour period in the original hourly record and to
the left of that, the date.

287608 24 / 10 / 1989 287608:287631            13.4
287609 24 / 10 / 1989 287609:287632            13.4
287610 24 / 10 / 1989 287610:287633            13.4
287611 24 / 10 / 1989 287611:287634            13.4
287612 24 / 10 / 1989 287612:287635            13.4
287613 24 / 10 / 1989 287613:287636            13.4
287614 24 / 10 / 1989 287614:287637            13.4
287615 24 / 10 / 1989 287615:287638            13.4
287616 24 / 10 / 1989 287616:287639            13.4

I somehow need to ensure the independence of my rainfall events, for
example by making sure that there are at least 2 days (48 hours) between
each of the top 50 storm events.
Can anyone suggest an approach I could use, or have you done this kind
of work before?
I have tried using a loop, however I'm not particularly experienced in
their use and an not convinced it is even the right approach?  I need to
extract the whole line of data, not just the rainfall amount.
Thanks
Jamie Ledingham



More information about the R-help mailing list