> str(presidential)
'data.frame': 7 obs. of 4 variables:
$ name : chr "Nixon" "Ford" "Carter" "Reagan" ...
$ start: Date, format: "1969-01-20" "1974-08-09" ...
$ end : Date, format: "1974-08-09" "1977-01-20" ...
$ party: chr "Republican" "Republican" "Democratic" "Republican" ...
Observe that start is a Date object - you want the numeric equivalent, because that's what is really plotted. This works for me in version
0.9.2.1:
unemp + geom_vline(aes(xintercept = as.numeric(start)), data = presidential)
Dennis
On Thu, Nov 1, 2012 at 11:13 AM, Brad Horn
<bxh...@gmail.com> wrote:
The following code appears in the book (p86) and the book website to illustrates the use of geom_vline:
unemp <- qplot(date, unemploy, data=economics, geom="line", xlab = "", ylab = "No. unemployed (1000s)")
presidential <- presidential[-(1:3), ]
yrng <- range(economics$unemploy)
xrng <- range(economics$date)
unemp + geom_vline(aes(xintercept = start), data = presidential)
In my case, I geom_vline is generating the following error:
Error: Discrete value supplied to continuous scale
Logic says I shouldn't get this error. Any help or insight is appreciated as I want to ensure the chart annotations are feasible.
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2