我有一个xts对象close
(带有POSIXct
索引)。当我运行 quantmod 命令specifyModel(close[,1] ~ close[,2])
时,它会出现此错误:
Error in UseMethod("as.xts") :
no applicable method for 'as.xts' applied to an object of class "function".
ALBK ANDHRABANK AXISBANK BANKBARODA
2007-01-02 10:01:00 90.89 87.33 468.55 243.95
2007-01-02 10:02:00 90.80 86.92 467.75 243.70
2007-01-02 10:03:00 90.45 86.77 468.65 243.60
2007-01-02 10:04:00 90.31 86.94 468.32 243.95
2007-01-02 10:05:00 90.27 87.05 468.60 244.00
2007-01-02 10:06:00 90.23 87.00 468.00 243.65
2007-01-02 10:07:00 90.24 86.89 467.50 243.60
2007-01-02 10:08:00 89.99 86.77 467.05 243.00
2007-01-02 10:09:00 90.05 86.80 467.40 243.00
2007-01-02 10:10:00 90.20 87.00 467.00 243.00
这个错误意味着什么,我该如何解决?
答案 0 :(得分:2)
它变得混乱,因为close
是基本R函数的名称。 (可能是一个错误,但我不确定使用的specifyModel
有多广泛)
> close <- getSymbols("SPY", src="yahoo", auto.assign=FALSE)
> specifyModel(close[, 1] ~ close[, 2])
Error in UseMethod("as.xts") :
no applicable method for 'as.xts' applied to an object of class "function"
通过重命名xts对象进行修复
> dat <- close
> specifyModel(dat[, 1] ~ dat[, 2])
quantmod object: Build date:
Model Specified:
dat[, 1] ~ dat[, 2]
Model Target: [ dat 0.1 Product: dat
Model Inputs:
Fitted Model:
None Fitted
>