问题
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