數據格式:如何繪製R中的使用時間爲xlabel
13年4月15日8:59 0.56525
13年4月15日上午9點0.8123
我想使用第二和第三列分別繪製R中的圖形,分別爲xlabel和ylabel。
Thx。
數據格式:如何繪製R中的使用時間爲xlabel
13年4月15日8:59 0.56525
13年4月15日上午9點0.8123
我想使用第二和第三列分別繪製R中的圖形,分別爲xlabel和ylabel。
Thx。
你可以試試這段代碼,看它是否符合你的要求。
library(ggplot2)
library(scales)
sample <- structure(list(Date = structure(c(1L, 1L), .Label = "4/15/2013", class = "factor"),
Time = structure(1:2, .Label = c("8:59:00 AM", "9:00:00 AM"
), class = "factor"), Value = c(0.56525, 0.8123)), .Names = c("Date",
"Time", "Value"), class = "data.frame", row.names = c(NA, -2L
))
time <- strptime(sample$Time," %H:%M")
qplot(time,sample$Value)+xlab("Time")+ylab("Value")+scale_x_datetime(breaks=date_breaks("1 min"), minor_breaks=date_breaks("10 sec"))
我希望它有幫助。
你只有兩點。如果你有更多的分數,那麼繪製和可視化效果會更好。
謝謝。該記錄由3萬行組成。 – user2263305
@Jdbaba:要求upvote在SO上皺起眉頭..要小心,以免引起主持人的憤怒:) –
你想繪製時間與數據?你不想陰謀一年。你只想繪製時間和數據。是對的嗎 ? –
肯定感謝只是繪製時間和數據 – user2263305