Re: [R] Sliding Window Time Series Analysis - hourly rainfall

From: jim holtman <jholtman_at_gmail.com>
Date: Thu, 24 Jan 2008 20:13:51 -0500

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?

______________________________________________
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.
Received on Fri 25 Jan 2008 - 01:16:19 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 25 Jan 2008 - 02:30:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive