Re: [R] ggplot2 - Problem with grid plot

From: Chris Friedl <>
Date: Tue, 04 Mar 2008 16:24:01 -0800 (PST)

ONKELINX, Thierry wrote:
> Dear Chris,
> You'll need to add information on the facet factor (color) to the
> medians dataset.
> library(ggplot2)
> medians <- aggregate(diamonds$price, list(cut = diamonds$cut, color =
> diamonds$color), median)
> ggplot(data=diamonds, aes(x=price)) + geom_density(aes(color=cut)) +
> geom_vline(data=medians, aes(color=cut, intercept = x)) +
> facet_grid(color~.)
> HTH,
> Thierry

As they say downunder, YOU BLOODY BEAUTY!!!! (that's a good thing :) Not only can I now create the plot I want, but I also learned the aggregate function which is exactly what I was looking for as a way of trying to solve this problem. R has a steep learning curve but as you go up the view gets better and better. Thanks again for your help Thierry. And Hadley, thanks again for ggplot ... I'm appreciating its power with each day.

View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Wed 05 Mar 2008 - 00:26:44 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 05 Mar 2008 - 00:30:20 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive