R语言程序错误如何解决

Error in c.xts(c(NA_real_, NA_real_), c(-0.0126221099907902, -0.0035023134030201, :
zero-length vectors with non-zero-length index are not allowed
请问这个是什么问题,如何解决?

可能导入了dplyr包,其lag函数中有NA值。要么不要导入包dplyr,要调用stats::lag()
参考一下这里解释:
https://stackoverflow.com/questions/62822653/zero-length-error-when-trying-to-lag-xts-time-series