1

我有一个大的时间序列数据,头部是:

             date_time         V1       V2 V3      V4     V5
13 2012-10-13 17:40:00 10/13/2012 17:40:00  0 15.8604 25.706
14 2012-10-13 18:00:00 10/13/2012 18:00:00  0 15.8508 25.688
15 2012-10-13 18:20:00 10/13/2012 18:20:00  0 15.8615 25.688
16 2012-10-13 18:40:00 10/13/2012 18:40:00  0 15.8637 25.686
17 2012-10-13 19:00:00 10/13/2012 19:00:00  0  15.868 25.686
18 2012-10-13 19:20:00 10/13/2012 19:20:00  0 15.8701 25.686

当我尝试在 R 中绘制数据时,它显示了正确的趋势,但 y 轴刻度完全不同,最大值为 12000(请参见此处:https ://docs.google.com/file/d/0B6GUNg-8d30vcG5KdDkxOXR0QkU /edit?usp=sharing )?!? 但是,我的任何其他数据图都没有遇到过如此奇怪的问题。

plot(date_time, data$V4, type='l', ylab = '??')

我的第二个问题——我的 date_time (class: "POSIXlt" "POSIXt") 默认显示 "month"。是否可以在不使用 strftime() 和/或 aggregate() 的情况下显示为“月-年”?

4

1 回答 1

0

目前尚不清楚您是否解决了第一个问题。否则,对于第二个问题,您可以使用axis.POSIXctwith xaxt="n" 手动绘制轴:

plot(x=data$date_time, y=data$V4, type='l', ylab = '??',xaxt="n") ## note here 
axis.POSIXct(1, at=data$date_time,format='%b %Y')

在此处输入图像描述

这是我的数据:

structure(list(date_time = structure(c(1350142800, 1350144000, 
1350145200, 1350146400, 1350147600, 1350148800), class = c("POSIXct", 
"POSIXt"), tzone = ""), V1 = structure(c(1L, 1L, 1L, 1L, 1L, 
1L), .Names = c("13", "14", "15", "16", "17", "18"), .Label = "10/13/2012", class = "factor"), 
    V2 = structure(1:6, .Names = c("13", "14", "15", "16", "17", 
    "18"), .Label = c("17:40:00", "18:00:00", "18:20:00", "18:40:00", 
    "19:00:00", "19:20:00"), class = "factor"), V3 = structure(c(1L, 
    1L, 1L, 1L, 1L, 1L), .Names = c("13", "14", "15", "16", "17", 
    "18"), .Label = "0", class = "factor"), V4 = structure(c(2L, 
    1L, 3L, 4L, 5L, 6L), .Names = c("13", "14", "15", "16", "17", 
    "18"), .Label = c("15.8508", "15.8604", "15.8615", "15.8637", 
    "15.8680", "15.8701"), class = "factor"), V5 = structure(c(3L, 
    2L, 2L, 1L, 1L, 1L), .Names = c("13", "14", "15", "16", "17", 
    "18"), .Label = c("25.686", "25.688", "25.706"), class = "factor")), .Names = c("date_time", 
"V1", "V2", "V3", "V4", "V5"), row.names = c("13", "14", "15", 
"16", "17", "18"), class = "data.frame")
于 2013-07-06T15:09:07.580 回答