[R] ggplot2 - extracting values of smooth

dM/ david.n.menezes at gmail.com
Fri Sep 30 18:39:23 CEST 2011

Suppose that I'm working on Hadley's diamond dataset and I want to
review the relationship between price, colour and carat.

I might run the following:


#plot scatter and add some hex binning
     q<-qplot(carat,price,data=diamonds, geom=c("hex"),
             main="Variability of Diamond Prices by Carat and Colour")

#facet to get one scatter for each colour, plus overlay a black
coloured loess smoothed line showing the trends in the data

    q +

Nice picture, but how do I extract the values of the smoothed line?

Many thanks, dM/

More information about the R-help mailing list