(meant to post this to the entire list)
Hi Jim-
this kind of pulling stats out is not really officially sanctioned, but it can be done. in fact, using the ggplot_build() as I used before to check the calculated box plots. When I asked about doing this, Koshke mentioned that i can not rely on it to exist in the future...
the only problem with this is that you'll have to do a smoothing spline or feed some other param to stat_smooth to get the value at every data point.
z<- rnorm( 1000)
f=data.frame( x=1:length(z), y=z)
g <- ggplot( f, aes( x=x, y=y) ) + stat_smooth(method='lm') + geom_point()
gb <- ggplot_build( g )
str(gb$data)
List of 2
$ 1:List of 1
..$ :'data.frame': 80 obs. of 6 variables:
.. ..$ y : num [1:80] -0.0331 -0.0325 -0.032 -0.0314 -0.0308 ...
.. ..$ ymin : num [1:80] -0.159 -0.156 -0.153 -0.15 -0.147 ...
.. ..$ ymax : num [1:80] 0.0926 0.0907 0.0889 0.0872 0.0854 ...
.. ..$ x : num [1:80] 1 13.6 26.3 38.9 51.6 ...
.. ..$ se : num [1:80] 0.064 0.0628 0.0616 0.0604 0.0592 ...
.. ..$ group: num [1:80] 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "dim")= int [1:2] 1 1
$ 2:List of 1
..$ :'data.frame': 1000 obs. of 3 variables:
.. ..$ y : num [1:1000] -0.95 -0.883 1.429 1.78 -0.922 ...
.. ..$ group: num [1:1000] 1 1 1 1 1 1 1 1 1 1 ...
..- attr(*, "dim")= int [1:2] 1 1
James