require(quantmod)
require(PerformanceAnalytics)
getSymbols('INTC')
x<- monthlyReturn(INTC)
rollapply(1+x,12,cumprod)
鉴于上面的代码,我得到了这个错误
Error in array(r, dim = d, dimnames = if (!(is.null(n1 <- names(x[[1L]])) & :
length of 'dimnames' [1] not equal to array extent
我可以验证 x 的类确实是 xts。
类(x)[1]“xts”“动物园”
我想 rollapply 适用于 xts/zoo 对象。我不确定如何解决这里的问题。
谢谢您的帮助。
更新
会话信息输出:
R version 2.15.3 (2013-03-01)
Platform: i686-pc-linux-gnu (32-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] PerformanceAnalytics_1.1.0 quantmod_0.4-0 TTR_0.22-0
[4] xts_0.9-3 zoo_1.7-9 Defaults_1.1-1
loaded via a namespace (and not attached):
[1] grid_2.15.3 lattice_0.20-13 tools_2.15.3