title: Create equal length vectors from time series based upon factor in R
body: <p>I have a data frame that is something like this:</p>
  
  <pre><code>time type count
  1   -2    a     1
  2   -1    a     4
  3    0    a     6
  4    1    a     2
  5    2    a     5
  6    0    b     3
  7    1    b     7
  8    2    b     2
  </code></pre>
  
  <p>I want to create a new data frame that takes type 'b' and creates the full time series by filling in zeroes for count. It should look like this:</p>
  
  <pre><code>time type count
  1   -2    b     0
  2   -1    b     0
  3    0    b     3
  4    1    b     7
  5    2    b     2
  </code></pre>
  
  <p>I can certainly subset(df, df$type = 'b') and then hack the beginning and rbind, but I want it to be more dynamic just in case the time vector changes.</p>