0
library(ggplot2)
p <- qplot(date, unemploy, data = economics, geom = "line", xlab = "",
           ylab = "No. of unemployed(1000s)")
presidential <- presidential[-(1 : 3), ]
p + geom_vline(aes(xintercept = start) , data = presidential)

I want to do the plot like above. But I got an error,

Error in Ops.Date((x - from[1]), diff(from)) 

In Hadley Wickham's book ggplot2, the above code is ok. I have also viewed questions like mine. One solution is to use numeric form of date, but if I use numeric form, the x-axis would be numeric number not date. Could anyone help me figure out how to solve this problem? Thank you!

lacfo
  • 69
  • 3
  • 12

0 Answers0