从 R xts 对象中的每日时间序列到每周时间序列 [英] From daily time series to weekly time series in R xts object
问题描述
我正在使用 zoo 和 xts 包来分析财务数据.ts 包不是很合适,因为金融系列有周末,没有可用数据.
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.
我读到了 xts 包中的 apply 函数availbale
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)
apply.weekly(x, tail)
推荐答案
apply.weekly(x, tail)
不起作用,因为 tail
返回最后 6 个观察值默认情况下.使用 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.
这篇关于从 R xts 对象中的每日时间序列到每周时间序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!