[R] how to make monthly time series out of daily

Jannis bt_jannis at yahoo.de
Tue Jun 1 23:22:36 CEST 2010


I am not sure about specific timeseries objects, but using an ordinary 
vector with the values the aggregate() function works fine:

monthly.means <- aggregate(timeseries, mean, by=months)

months now only has to be a vector of length(timeseries) with numbers 
relating each entry in timeseries to a unique month. My (not very 
elegant) way would be to create a unique index by extracting the year 
and the month from a time vector and combining them into one number, so 
that 10.2001 would result in 200110. I am sure there are more elegant 
ways using timeseries objects or something similar.


HTH
Jannis


Reto Baumgartner schrieb:
> I am using the Rmetrics package and would like to convert a daily
> price time serie into a monthly one. In SPlus I could use:
> aggregateSeries(timeSerie, by="months",FUN=first).
>
> ______________________________________________
> 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.
>
>



More information about the R-help mailing list