我使用ggplot進行繪圖。 我想出了一個問題,代碼:ggplot2和strptime在R
require(ggplot2)
require(reshape2)
df <- data.frame(HMn25_30$avg,for30$cgsbi_1,dt_hmn$dt)
names(df)[1]='WSN 25'
names(df)[2]='MetoSwiss Forecast'
df.m <- melt(df, names(df)[3], names(df)[1:2])
df.m$dt_hmn.dt <- strptime(as.character(df.m$dt_hmn.dt), format = "%m/%d/%Y %H:%M:%S")
p <- ggplot(df.m, aes(x = dt_hmn.dt, y = value, group = variable, color = variable))
size=14),axis.text.y = element_text(angle=00, vjust=0.5, size=30))
p
數據:
> head(df.m)
dt_hmn.dt variable value
1 9/29/2007 23:00 WSN 25 0.280
2 9/30/2007 0:00 WSN 25 0.208
3 9/30/2007 1:00 WSN 25 -0.264
4 9/30/2007 2:00 WSN 25 -0.480
5 9/30/2007 3:00 WSN 25 -0.708
6 9/30/2007 4:00 WSN 25 -0.714
str(df.m)
'data.frame': 50 obs. of 3 variables:
$ dt_hmn.dt: Factor w/ 25 levels "9/29/2007 23:00",..: 1 2 3 14 19 20 21 22 23 24 ...
$ variable : Factor w/ 2 levels "WSN 25","MetoSwiss Forecast": 1 1 1 1 1 1 1 1 1 1 ...
$ value : num 0.28 0.208 -0.264 -0.48 -0.708 -0.714 -0.498 -0.216 0.126 0.574 ...
時,我想用
strptime
所有TIME_DATE欄更改爲「NA」
。
Plz在這件事上指導我。
是的,它在劇情網格是每6小時工作。每3或4小時能縮短一次嗎? –