【发布时间】:2020-10-30 12:12:18
【问题描述】:
我有使用以下生成的基本 xts 对象。
library(quantmod)
temp1 <- getSymbols("GOOG",src = 'yahoo',from=Sys.Date()-50,to = Sys.Date(),auto.assign=FALSE)
temp2 <- temp1$GOOG.Close
head(temp2)
GOOG.Close
2020-05-20 1406.72
2020-05-21 1402.80
2020-05-22 1410.42
2020-05-26 1417.02
2020-05-27 1417.84
2020-05-28 1416.73
lag(temp2,1)
Error in c.xts(NA_real_, c(1406.719971, 1402.800049, 1410.420044, 1417.02002, :
zero-length vectors with non-zero-length index are not allowed
据我所知 temp2 的长度不是零,所以我不明白这个错误。
同样,diff(temp2) 函数也能按预期工作。
这似乎是我最近更新到 R 4.0.1 时开始的
考虑到我确实有一个非零向量,我找不到任何关于此错误的解释。
【问题讨论】: