r - Getting a monthly time series from weekly data -



r - Getting a monthly time series from weekly data -

i've checked few questions on time series aggregation, haven't found looking for.

i have zoo object of weekly info on 10 years, , i've calculated monthly rolling mean of series. want work monthly info corresponds this, , end pull lastly weekly info point each month, representative whole month, separate time series.

i've tried aggregate ts function having problem since spacing not (i.e. 4 weeks not month, etc).

the fact months have different length should no problem. @ next example:

> library(xts) > dates <- as.date("2013-01-01") + 7*(0:52) > y.week <- zoo(rnorm(365),order.by=dates) > head(y.week) 2013-01-01 2013-01-08 2013-01-15 2013-01-22 2013-01-29 2013-02-05 0.3648757 -0.7247121 0.4815929 0.5967042 1.6272563 0.8472303 > y.mon <- aggregate(y.week, + = format(dates,format="%y-%m"), + fun=sum) > head(y.mon) 2013-01 2013-02 2013-03 2013-04 2013-05 2013-06 2.3457170 1.9640368 -0.3259688 -0.8710992 0.5430847 -0.1107915

look @ help page strptime see format strings can utilize in place of "%y-%m" above.

r time-series

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -