我有一个时间序列数据,我想用这段代码来绘制它:
temp <- read.csv("C:/Thesis/Data_set/grosseroor/25.csv",
header = FALSE)
names(temp) <- c("dt","ambtemp")
require(ggplot2)
library(scales)
temp$dt <-strptime(as.character(temp$dt), format = "%Y/%m/%d %H:%M")
ggplot(temp, aes(dt, ambtemp)) + geom_line() +
scale_x_datetime(breaks = date_breaks("5 hour"),labels=date_format("%H:%M")) +
xlab("Time 00.00 ~ 24:00 (2007-09-29)") + ylab("Tempreture")
样本数据:
date_time
10/20/2007 4:52 -6.14
10/20/2007 4:54 -6.17
10/20/2007 4:56 -6.09
10/20/2007 5:00 -7.2
10/20/2007 5:02 -6.65
10/20/2007 5:04 -6.04
10/20/2007 5:16 -6.26
10/20/2007 5:20 -6.52
10/20/2007 5:22 -6.4
10/20/2007 5:24 -6.92
10/20/2007 5:26 -7.04
10/20/2007 5:28 -6.84
10/20/2007 5:30 -6.16
10/20/2007 5:32 -7.13
10/20/2007 5:34 -7.43
10/20/2007 5:36 -6.84
10/20/2007 5:38 -7.82
10/20/2007 5:40 -6.84
10/20/2007 5:42 -6.84
10/20/2007 5:44 -7.46
10/20/2007 5:46 -7.74
10/20/2007 5:48 -8.04
但是当我运行该行时temp$dt <-strptime((temp$dt), format = "%Y/%m/%d %H:%M")
,所有日期时间列都更改为NA
.