在Zoo对象打印上需要有限的“xlim”值

2024-05-14 20:26:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下动物园对象:

x<-read.zoo("values.txt",format="%H:%M:%OS",sep=",",header=F,FUN=as.POSIXct)

x如下所示:

2015-01-20 17:39:56 367 0
2015-01-20 17:39:56 236 0
2015-01-20 17:39:58 542 0
2015-01-20 17:39:58 260 0

现在,我在第二个时间间隔上进行聚合,以获得每秒的值,而不是毫秒级别: > x_uniq<-aggregate(x,format(time(x),"%H:%M:%S"),mean)

xu uniq如下所示:

17:39:55 403.0000 0.0
17:39:56 301.5000 0.0
17:39:58 401.0000 0.0
17:40:00 607.0000 0.0

当我试图绘制它时,却得到了以下错误:

plot(x_uniq,plot.type = "single", col = c("red", "blue"),lwd = 2)
错误绘图窗口(…):需要有限的“xlim”值
另外:警告消息:
1: 在xy坐标介绍人:Abel,Yal/> 2: In min(x):min没有不丢失的参数;返回Inf
3: 在max(x):max没有不丢失的参数;返回-Inf

因为现在我已经把它转换成了现在的角色。但我不知道怎么把它换回去。谁能帮忙吗? 谢谢!在


Tags: 对象txtformatread参数plotos错误
1条回答
网友
1楼 · 发布于 2024-05-14 20:26:45

这个问题省略了输入,只显示了read.zoo语句的输出,因此我们不知道您有什么,但假设它看起来像下面这样尝试:

Lines <- 
"2015-01-20 17:39:56,367,0
2015-01-20 17:39:56,236,0
2015-01-20 17:39:58,542,0
2015-01-20 17:39:58,260,0"

library(zoo)
z <- read.zoo(text = Lines, sep = ",", tz = "", aggregate = mean)
plot(z)

相关问题 更多 >

    热门问题