title: ggplot2: add line for sum of group values at each x
body: <p>Let's say I collect the posts in Stack Overflow and I classify them in N categories. My goal is to plot the N percentage  every day and a line with the total number of posts per day.</p>
  
  <p>To play with, I'll use a toy dataframe. I can plot the percentage of every category per day:</p>
  
  <pre><code>data(beav1)
  beav1$day &lt;- as.factor(beav1$day)
  beav1[beav1$day==346,]$time &lt;- 1:sum(beav1$day==346)
  beav1[beav1$day==347,]$time &lt;- 1:sum(beav1$day==347)
  beav1 &lt;- filter(beav1, time&lt;23)
  ggplot(beav1, aes(x=time, y=temp, group=day, fill=day, color=day)) + 
    geom_line()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/oEBzw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oEBzw.png" alt="enter image description here"></a></p>
  
  <p>But how can I add the line with the total temperature? Or the mean?</p>
  
  <p><strong>Edit</strong>: The difference with <a href="https://stackoverflow.com/questions/32504313/how-to-add-horizontal-lines-showing-means-for-all-groups-in-ggplot2">this other question</a> is that I would like one single line for all the groups and not a line per group.</p>
  
  <p><strong>dataset</strong></p>
  
  <pre><code>dput(beav1)
  structure(list(day = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
  1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 
  2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
  2L, 2L, 2L, 2L, 2L), .Label = c("346", "347"), class = "factor"), 
      time = c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 
      13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 22L, 1L, 2L, 
      3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 
      16L, 17L, 18L, 19L, 20L, 21L, 22L), temp = c(36.33, 36.34, 
      36.35, 36.42, 36.55, 36.69, 36.71, 36.75, 36.81, 36.88, 36.89, 
      36.91, 36.85, 36.89, 36.89, 36.67, 36.5, 36.74, 36.77, 36.76, 
      36.78, 36.82, 36.93, 36.83, 36.8, 36.75, 36.71, 36.73, 36.75, 
      36.72, 36.76, 36.7, 36.82, 36.88, 36.94, 36.79, 36.78, 36.8, 
      36.82, 36.84, 36.86, 36.88, 36.93, 36.97), activ = c(0L, 
      0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
      0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
      0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), class = "data.frame", row.names = c(NA, 
  -44L), .Names = c("day", "time", "temp", "activ"))
  </code></pre>