plot running average in ggplot2
<p>I'm hoping to create a plot that shows a running average over a scatterplot of the observed data. The data consists of observations of hares' coat color (Color) over time (Julian). </p>

<pre><code>Color  Julian
50  85
50  87
50  89
50  90
100 91
50  91
50  92
50  92
100 92
50  93
100 93
50  93
50  95
100 95
50  95
50  96
50  96
50  99
50  100
0   101
0   101
0   103
50  103
50  104
50  104
50  104
50  104
100 104
100 104
50  109
50  109
100 109
0   110
0   110
50  110
50  110
50  110
50  110
0   112
</code></pre>

<p>A friend wrote a function for me that calculates a running average of the color observations, but I can't figure out how to add the line (haresAveNoNa) into the plot. </p>

<p>The function:</p>

<pre><code>haresAverage &lt;- matrix( NA, max(hares$Julian), 3 )
for( i in 4:max(hares$Julian) ){
  haresAverage[i,1]&lt;-i
  haresAverage[i,2]&lt;-mean( hares$Color[ hares$Julian &gt;= (i-3) &amp;
                                             hares$Julian &lt;= (i+3)]
                              , na.rm=T )
  haresAverage[i,3]&lt;-sd( hares$Color[ hares$Julian &gt;= (i-3) &amp;
                                           hares$Julian &lt;= (i+3)]

                            , na.rm=T )
}
haresAveNoNa &lt;- na.omit( haresAverage)
</code></pre>

<p>The plot:</p>

<pre><code>p &lt;- ggplot(hares, aes(Julian, Color))
p  +
  geom_jitter(width = 1, height = 5, color="blue", alpha = .65) 
</code></pre>

<p>Can you please help me add the running average 'haresAveNoNa' into the plot?
Thanks very much!</p>