0
我想添加指定X限制值的垂直線。我的數據:Geom_vline時間值
meltk1=structure(list(variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = "number", class = "factor"),
value = c(0L, 85L, 65L, 35L, 28L, 124L), Hour = c("00:23:00",
"00:29:00", "00:53:00", "04:51:00", "05:08:00", "05:23:00"
)), .Names = c("variable", "value", "Hour"), row.names = c(168L,
169L, 170L, 1L, 2L, 3L), class = "data.frame")
Hour
是,當我測量的變量,沒有日期的時間指定的時間。正如我在少數帖子中看到的那樣,geom_vline
的問題是它需要一個日期。因爲,我不需要有日期的信息。我如何在沒有日期的情況下使用geom_vline?
按照我正在嘗試使用的代碼,但不適用於簡單日期。有沒有其他的as.POSIXct
替代品?此代碼在Hour
具有此格式2017-08-15 07:32:00 CEST
和POSIXct("2017-08-15 00:53:00")
時有效。但我只想要Hour
作爲時間。
ggplot(meltk1, aes(x=Hour, y = value, group = variable, colour = variable)) +
geom_line(size=1) +
geom_vline(aes(xintercept = as.numeric(as.POSIXct("00:53:00"))), color = "black", linetype = "dashed")
第一種解決方案很適合,非常感謝。 – ranell