0
一个xlab考虑提供与下面的代码情节一个情节:如何垂直线添加到具有在时间格式
x<-seq(as.POSIXct("2016-01-01 00:05:00"), as.POSIXct("2016-01-02 00:00:00"), by = '5 min')
t<-as.POSIXct("2016-01-01 07:08:32")
y<-c(1:288)
df<-data.frame(x,y)
library('ggplot2')
p<-ggplot(data=df,aes(x,y))+geom_point()
p
现在我想添加一个垂直线,其定位在2016-01-01 07:08:32
,所以我尝试以下:
p+geom_vline(xintercept=as.POSIXct("2016-01-01 07:08:32"))
然而,这不是解决方案,它返回:
Error in Ops.POSIXt((x - from[1]), diff(from)) :
'/' not defined for "POSIXt" objects
我怎样才能得到正确的结果?