From daily time series to weekly time series in R xts object

一世执手 提交于 2019-12-12 20:34:09

问题


I'm using the zoo and xts package for analysing financial data. ts package is not very suitable since financial series have weekend with no data available.

I read about the apply function availbale in the xts package

apply.daily(x, FUN, ...)
apply.weekly(x, FUN, ...)
apply.monthly(x, FUN, ...)
apply.quarterly(x, FUN, ...)
apply.yearly(x, FUN, ...)

this apply function over calendar periods and thought that something like that will work in order to get the end of week value but it seems not to work.

apply.weekly(x, tail)


回答1:


apply.weekly(x, tail) doesn't work because tail returns the last 6 observations by default. Use apply.weekly(x, tail, 1) instead.



来源:https://stackoverflow.com/questions/16402915/from-daily-time-series-to-weekly-time-series-in-r-xts-object

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!