2

我需要用R绘制一组数据(1M 行) 。时间列(第 1 列)采用 hh:mm:ss.000 格式。我想在一个时间范围内绘制图表,比如从 08:05:00 到 09:00:00。我该怎么做?我在网上搜索,但找不到正确设置 xlim 的方法。

这是数据的一个简短示例。第 1 列是时间,第 2、3、4.. 列将在 y 轴上。07:51:19.553,10.785,0.000,0.392,1.512,1.527,1.553,1.560,2.838

08:05:00.661,-1.555,0.000,0.041,0.310,0.314,0.321,0.327,1.474

08:06:58.250,30.781,0.000,0.093,0.156,0.160,0.168,0.173,1.411

08:30:02.506,-0.002,0.000,0.052,0.120,0.123,0.132,0.137,1.361

09:05:00.997,-1.802,0.000,0.032,0.078,0.080,0.087,0.090,1.258

10:05:00.661,-1.555,0.000,0.041,0.310,0.314,0.321,0.327,1.474

在此先感谢您的帮助。

4

2 回答 2

3

真的想使用适当的时间序列类,例如zooxts

子集,绘图,......然后免费提供。在切换到xts以获得更好的性能和子集之前,先从优秀的zoo文档开始。

现在,一百万行太多了,因为你最终得到的数据多于像素——但至少这会给你一个总结数据的机会。

这是一个简单的说明:

> options(digits.sec=3)      ## important: turn on milli-sec via print()
> library(xts)
Loading required package: zoo
> X <- xts(cumsum(rnorm(100)), order.by=Sys.time()+cumsum(runif(100)/10))
> plot(X)
于 2010-07-26T17:53:52.230 回答
1

要将字符向量更改为“日期和时间”对象,POSIXlt(ct) 对象,函数将派strptime()上用场。这是一个简短的示例,它是如何完成的。

dtm <-  strptime(c("1.1.2010 11:35"), format =  "%d.%m.%Y %H:%M", tz = "CET")
于 2010-07-26T18:45:13.913 回答