R绘图时间序列数据:极短时间圈

R绘图时间序列数据:极短时间圈,r,time-series,R,Time Series,我有下面的数据框。时隙之间的间隔不同,有时小,有时大: history <- structure(list(timestamp = structure(1:13, .Label = c("2006-06-11 04:43:56", "2006-06-11 04:47:24", "2006-06-11 04:47:54", "2006-06-11 04:49:37", "2006-06-11 04:52:12", "2006-06-11 04:58:22", "2006-06-11 05:0

我有下面的数据框。时隙之间的间隔不同,有时小,有时大:

history <- structure(list(timestamp = structure(1:13, .Label = c("2006-06-11 04:43:56",
"2006-06-11 04:47:24", "2006-06-11 04:47:54", "2006-06-11 04:49:37",
"2006-06-11 04:52:12", "2006-06-11 04:58:22", "2006-06-11 05:01:11",
"2006-06-11 05:06:56", "2006-06-11 05:14:35", "2006-06-11 05:21:44",
"2006-08-21 19:55:50", "2006-08-21 19:56:31", "2007-11-22 22:09:17"
), class = "factor"), page_length = c(1753, 146, 2401, 461, 113,
1248, 1268, 720, 1290, 436, 531, 502, 746)), .Names = c("timestamp",
"page_length"), row.names = c(NA, -13L), class = "data.frame")

history
#             timestamp page_length
#1  2006-06-11 04:43:56        1753
#2  2006-06-11 04:47:24         146
#3  2006-06-11 04:47:54        2401
#4  2006-06-11 04:49:37         461
#5  2006-06-11 04:52:12         113
#6  2006-06-11 04:58:22        1248
#7  2006-06-11 05:01:11        1268
#8  2006-06-11 05:06:56         720
#9  2006-06-11 05:14:35        1290
#10 2006-06-11 05:21:44         436
#11 2006-08-21 19:55:50         531
#12 2006-08-21 19:56:31         502
#13 2007-11-22 22:09:17         746
正如你在图中看到的,我想在短时间间隔之间获得一个良好的分离
type='l'
表示绘图类型为直线。所以它向你展示了一条线。。。您可能需要
type='p'
,即点

查看更多信息并查看一些R绘图教程,这些教程已经足够多了

我使用来表示时间序列,我使用来生成(我认为)您想要的图表类型。(我也尽可能避免使用
POSIXlt
,因为它比
POSIXct
更慢,占用更多内存)


实际上,这个问题更适合StackOverflow,因为它是关于编程的。
plot(as.POSIXlt(history$timestamp,format='%Y-%m-%d %H:%M:%S'), 
     log(history$page_length), xlab= "Months", ylab= "log page Length", type='l', col='red') 
library(quantmod)
x <- xts(history[, 2], as.POSIXct(history[, 1]))
chartSeries(log(x), theme="white")
plot(head(axTicksByTime(x), -1), log(x), type="l", col="red")