title: ggplot2 - referecing summary statistics / layers
body: <p>I've picked-up the ggplot2 book but I'm struggling to understand how data persists through layers.</p>
  
  <p>For example, lets take a dataset and calculate the mean of each X:</p>
  
  <pre><code>thePlot = ggplot( myDF , aes_string( x = "IndepentVar" , y = "DependentVar" ) )
  thePlot = thePlot + stat_summary( fun.y = mean , geom = "point" )
  </code></pre>
  
  <p>How do I "access" the summary statistics in the next layer?  For example, lets say I want to plot a smooth line over the dataset.  This seems to work:</p>
  
  <pre><code>thePlot = thePlot + stat_smooth( aes( group = 1 ) , method = "lm" , geom = "smooth" , se = FALSE )
  </code></pre>
  
  <p>But lets say I want to further ignore a particular X value when generating the line?  How do I reference the summarized dataset to express excluding a particular X?</p>
  
  <p>More generally, how is data referenced as it flows through layers?  Am I always limited to the last statistics?  Can I reference the original dataset?</p>