[R] aggregating daily values

Achim Zeileis Achim.Zeileis at wu-wien.ac.at
Tue Jun 26 20:42:16 CEST 2007


On Tue, 26 Jun 2007, antonio rodriguez wrote:

> Hi,
>
> I swear I have read almost all the posted messages about this issue, but
> it's evident I couldn't find an answer (surely esay) to my problem. What
> I want is the following:
>
> Make  8 days aggregates from a daily series like this (dput output):

I'm not sure which days you want to aggregate exactly. If you want to
replace the observations from 1985-01-02 until 1985-01-09 by a single
observation, maybe you want something like
  new.time <- as.Date(8 * floor(as.numeric(time(z))/8) + 7)
  z2 <- aggregate(z, new.time, mean)
which gives averages for 8 days (anchored on the last day of the 8-day
period).

Does this what you're looking for? Look at the "zoo" vignettes for more
information/examples.
Z



More information about the R-help mailing list