title: How to aggregate variable by time period for time series plot in R using ggplot2
body: <p>I would like to create a time series plot using <code>ggplot2</code> in which the variable plotted over time. However, for each time period, I would like to plot the cumulative count for that period. For example:</p>
  
  <pre><code>set.seed(123)
  frame &lt;- data.frame(id = sort(rep(c(0:5), 5)),year = rep(c(2000:2005), 5), y = sample(0:1,30, replace = TRUE))
  table(frame$year, frame$y)
  ggplot(frame, aes(x = year, y = y)) + geom_point(shape = 1) # Not right
  </code></pre>
  
  <p>I would ultimately like it to generate a plot like this:</p>
  
  <pre><code>count&lt;- table(frame$year, frame$y)[,2]
  plot(2000:2005, count, type = "l")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5jvyx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5jvyx.png" alt="enter image description here"></a></p>
  
  <p>I'm new to <code>ggplot</code> and any pointers would be greatly appreciated. Thanks. </p>