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@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.

Reply via email to