我有一个很大的时间序列数据,头是:
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(类:“POSIXlt”“POSIXt”)默认显示“月”。是否可以在不使用strftime()和/或aggregate()的情况下显示为“月 - 年”?
答案 0 :(得分:0)
目前尚不清楚您是否已解决了第一个问题。否则,对于第二个问题,您可以使用axis.POSIXct
和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")