以下代码一直有效,直到最近。
library("quantmod")
library("PerformanceAnalytics")
library("ggplot2")
library("fPortfolio")
library("fAssets")
library("reshape2")
library("corrplot")
library("gridExtra")
library("dplyr")
Data_SP <- new.env()
### Download the data from yahoo finance
SP_tickers<-c("SPY","AAGPX","AUIAX","BHBFX","CABDX","CGRWX","EHSTX","HDGYX","KDCAX","LEIFX","NBPBX","OLVAX","PGRWX")
start.time<-proc.time()
getSymbols(SP_tickers, from="1998-12-29", env=Data_SP)
Returns <- eapply(Data_SP, function(s) ROC(Ad(s), type="discrete"))
proc.time()-start.time
系统返回时出现以下错误:
Error in lag(x, n, na.pad = na.pad) : unused argument (na.pad = na.pad)
有关如何重新开始上述工作的任何建议吗?
(自出现此错误以来,所有包都已更新)
Traceback下方:
4 lag(x, n, na.pad = na.pad)
3 ROC(Ad(s), type = "discrete")
2 FUN(list(structure(c(20.7, 20.57, 20.49, 20.52, 20.76, 21.2,
21.22, 21.42, 21.21, 20.84, 20.73, 20.27, 20.74, 20.83, 20.84,
20.57, 20.35, 20.41, 20.53, 20.3, 20.6, 20.82, 20.62, 20.48,
20.62, 20.35, 20.32, 20.32, 20.01, 20.1, 20.39, 20.1, 20.28, ...
1 eapply(Data_SP, function(s) ROC(Ad(s), type = "discrete"))
答案 0 :(得分:1)
找出实际来自哪个包lag
。
您加载了哪些包以及按什么顺序加载?
显然dplyr::lag()
不同意xts::lag()
https://github.com/hadley/dplyr/issues/277
“但是如果我们现在附加了dplyr库,它就不会扩展滞后泛型函数。它用一个破坏xts功能的显式函数替换它。”