[R] ggplot2 adding vertical line at a certain date

stephen sefick ssefick at gmail.com
Wed May 27 20:31:23 CEST 2009


library(ggplot2)

melt.updn <- (structure(list(date = structure(c(11808, 11869, 11961, 11992,
12084, 12173, 12265, 12418, 12600, 12631, 12753, 12996, 13057,
13149, 11808, 11869, 11961, 11992, 12084, 12173, 12265, 12418,
12600, 12631, 12753, 12996, 13057, 13149), class = "Date"), variable =
structure(c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L), .Label = c("unrestored",
"restored"), class = "factor"), value = c(1.1080259671261, 0.732188576856918,
0.410334408061265, 0.458980396410056, 0.429867902470711, 0.83126337241925,
0.602008712602784, 0.818751283264408, 1.12606382402475, 0.246174719479079,
0.941043753226865, 0.986511619794787, 0.291074883642735, 0.346361775752625,
1.36209038621623, 0.878561166753624, 0.525156715576168, 0.80305564765846,
1.08084449441812, 1.24906568558731, 0.970954515841768, 0.936838439269239,
1.26970090246036, 0.337831520417547, 0.909204325710795, 0.951009811036613,
0.290735620653709, 0.426683515714219)), .Names = c("date", "variable",
"value"), row.names = c(NA, -28L), class = "data.frame"))

qplot(date, value, data=melt.updn, shape=variable)+geom_smooth()

#I would like to add a line at November 1, 2002
#thanks for the help

-- 
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

								-K. Mullis



More information about the R-help mailing list