2

下面的代码一直有效,直到最近。

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) 

任何建议如何让上述工作再次?

(出现此错误后,所有软件包均已更新)

回溯下方:

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")) 
4

1 回答 1

1

找出lag实际来自哪个包。你加载了哪些包,按什么顺序加载?

显然dplyr::lag()不同意xts::lag() https://github.com/hadley/dplyr/issues/277

“但如果我们现在附加 dplyr 库,它不会扩展 lag 通用函数。它用一个破坏 xts 功能的显式函数替换它。”

于 2014-10-28T05:52:01.083 回答