[R] Sliding Window Time Series Analysis - hourly rainfall

jim holtman jholtman at gmail.com
Fri Jan 25 02:13:51 CET 2008


Take a look at "filter" for doing a moving average.

On Jan 24, 2008 6:48 AM, Jamie Ledingham
<jamie.ledingham at newcastle.ac.uk> wrote:
> I have a time series of rainfall in a dataframe.  I would like to be
> able to aggregate this using a sliding window approach- i.e. a new 24
> hourly total is calculated for each hours rainfall.  I'm struggling to
> understand how this might be achieved - currently I've tried looping a
> sum function to re-calculate a new total at every stage of the loop.
>
> for (inp[[9]] in 1:length(inp[[9]])){data.frame(x<-sum(inp[y:y+24,9]))}
>
> where inp is the data frame object and [[9]] is the column containing
> rainfall.
> y is used to try and get the previous 24 hours total however in it's
> current state it seems useless.
>
> If anyone could give me some pointers i'd be very pleased, I'm a bit new
> to the R language so any help appreciated.
> Thanks
> Jamie Ledingham
>
> ______________________________________________
> 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.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?



More information about the R-help mailing list