绘制 xts if (on == "years") { 错误:需要 TRUE/FALSE 的缺失值 [英] plot xts Error in if (on == "years") { : missing value where TRUE/FALSE needed

查看:35
本文介绍了绘制 xts if (on == "years") { 错误:需要 TRUE/FALSE 的缺失值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制一个 xts 对象,但我得到了一个关于年份的错误.. xts 对象只有一个数值和一个 POSIXct 索引.下面是显示 xts 和尝试绘图时错误的代码.关于需要对 xts 对象做什么才能正确绘图的任何想法?

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

推荐答案

您的目标是什么?plot.xts 函数不会绘制少于 3 个点的问题吗?xts::axTicksByTime 会抛出错误,因为最小中断次数是 2.尝试将不同的参数传递给 axTicksByTime 会因 中的编码而受挫plot.xts 里面没有 ... 机制.

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.

这篇关于绘制 xts if (on == "years") { 错误:需要 TRUE/FALSE 的缺失值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆