title: How to add a mean line to a xyplot in R?
body: <p>Hi I am trying to add a mean line to a lattice xyplot using the following code... which doesn't work...</p>
  
  <pre><code>library(lattice)
  temp &lt;- data.frame(c(1,1,1,1,1,1,2,2),
        c(1,1,2,2,1,1,1,1),
        c(1,1,1,2,1,2,1,2),
        c(0,0,0,150,150,0,0,0),
        c(3,10,4,15,14,2,4,5))
  names(temp) &lt;- c("instNo","NoOfAC","NoReleaseLevels","trExt","maxDelay")
  
  tempavg &lt;- aggregate(temp[5], by=list(temp$NoOfAC,temp$NoReleaseLevels
                                    ,temp$trExt),FUN = mean)
  
  names(tempavg) &lt;- c("NoOfAC","NoReleaseLevels","trExt","meanDelay")
  xyplot(maxDelay ~ NoOfAC |trExt + NoReleaseLevels,
               data = temp,
               panel = function(x, y, tempavg) {
                 panel.xyplot(x, y)
                 panel.abline(tempavg$meanDelay ~ y |trExt + NoReleaseLevels)
               },
  xlab = "Number Of Aircraft in the Instance",
  ylab = "Total Delay (minutes)")
  </code></pre>