plot xts Error in if (on == “years”) { : missing value where TRUE/FALSE needed

纵饮孤独 提交于 2020-01-03 16:45:23

问题


I am trying to plot an xts object but I get an error about years.. The xts object just has a numerical value and a POSIXct index. Below is the code that shows the xts and the error when trying plot. Any ideas on what needs to be done to a xts object to properly plot?

xTest<-as.xts(35, Sys.time())
xTest
##                           [,1]
## 2013-04-07 18:19:19.37238   35
class(xTest)
## [1] "xts" "zoo"
class(index(xTest))
## [1] "POSIXct" "POSIXt"

plot(xTest)
##  Error in if (on == "years") { : missing value where TRUE/FALSE needed

回答1:


What is your goal? Is there a problem that the plot.xts function will not plot fewer than 3 points? The error gets thrown by the xts::axTicksByTime because the minimum number of breaks is 2. Attempts to pass a different argument to axTicksByTime are frustrated by the coding in plot.xts which has no ... mechanism in it.



来源:https://stackoverflow.com/questions/15871059/plot-xts-error-in-if-on-years-missing-value-where-true-false-needed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!