[R] aggregating daily values

antonio rodriguez antonio.raju at gmail.com
Tue Jun 26 20:57:37 CEST 2007


Achim Zeileis escribió:
> 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
>
>
>
>   
It's a very good solution. And... if I want that the anchor is placed in 
the middle of the 8 days period?

Thanks,

Antonio

-- 
=====
Por favor, si me mandas correos con copia a varias personas, 
pon mi dirección de correo en copia oculta (CCO), para evitar 
que acabe en montones de sitios, eliminando mi privacidad, 
favoreciendo la propagación de virus y la proliferación del SPAM. Gracias.
-----
If you send me e-mail which has also been sent to several other people,
kindly mark my address as blind-carbon-copy (or BCC), to avoid its
distribution, which affects my privacy, increases the likelihood of
spreading viruses, and leads to more SPAM. Thanks.
=====
Antes de imprimir este e-mail piense bien si es necesario hacerlo: El medioambiente es cosa de todos.
Before printing this email, assess if it is really needed.



More information about the R-help mailing list