I am making a step graphic of "inventary levels" and I want to include horizontal segments at the level 5 in Y. So, I am importing my table from Excel. The first of the two columns has Dates with the format "2020-12-04" and R reads it very well.
I plot the data using geom_step
and it works perfectly, the X axis becomes the dates and the Y axis is the inventory level.
The problem is when I try to add a segment between to dates using geom_segment(aes(x=2020-12-04, y=5, xend=2020-12-12, yend=5 ))
it shows me:
Error: Invalid input: time_trans works with objects of class POSIXct only
How can I fix this? Here is the code I am using
Datos<-read_excel(ruta_excel, sheet="CDSYG", range="J4:K45")
p<-ggplot(data=Datos, aes(x=Dia, y=Nivel))
p+geom_step()+geom_segment(aes(x=2020-12-04, y=5, xend=2020-12-12, yend=5 ))