[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:
library(ggplot2)
#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 +
facet_wrap(~color,ncol=2)+geom_smooth(aes(group=1),colour=I("black"))
Nice picture, but how do I extract the values of the smoothed line?
Many thanks, dM/
More information about the R-help
mailing list