title: Add Moving average plot to time series plot in R
body: <p>I have a plot of time series in ggplot2 package and I have performed the Moving average and I would like to add the result of moving average to the plot of time series.</p>
  
  <p>Sample of Data-set (p31):</p>
  
  <p>ambtemp                  dt<br>
   -1.14 2007-09-29 00:01:57<br>
   -1.12 2007-09-29 00:03:57<br>
   -1.33 2007-09-29 00:05:57<br>
   -1.44 2007-09-29 00:07:57<br>
   -1.54 2007-09-29 00:09:57<br>
   -1.29 2007-09-29 00:11:57 </p>
  
  <p>Applied code for time series presentation:</p>
  
  <pre><code>  Require(ggplot2)
    library(scales)
    p29$dt=strptime(p31$dt, "%Y-%m-%d %H:%M:%S")
    ggplot(p29, aes(dt, ambtemp)) + geom_line() +
       scale_x_datetime(breaks = date_breaks("2 hour"),labels=date_format("%H:%M")) + xlab("Time 00.00 ~ 24:00 (2007-09-29)") + ylab("Tempreture")+
       opts(title = ("Node 29"))
  </code></pre>
  
  <p>Sample of time series presentation
  <img src="https://i.stack.imgur.com/dmQo2.png" alt="Sample of time series presentation"></p>
  
  <p>Sample of Moving average plot
  <img src="https://i.stack.imgur.com/IVeoM.png" alt="enter image description here">
  Sample of expected results</p>
  
  <p>The challenge is that time series data ov=btained from data-set which includes timestamps and temperature but Moving average data include just the average column and not the timestamps and fitting these two can cause inconsistency. </p>
  
  <p><img src="https://i.stack.imgur.com/aFgfu.png" alt="Expected Results"></p>