title: R - Insert Missing Numbers in A Sequence by Group's Max Value
body: <p>I'd like to insert missing numbers in the index column following these two conditions:</p>
  
  <ol>
  <li>Partitioned by multiple columns</li>
  <li>The minimum value is always 1</li>
  <li>The maximum value is always the maximum for the group and type</li>
  </ol>
  
  <p>Current Data:</p>
  
  <pre><code>group   type    index   vol
  A       1       1       200
  A       1       2       244
  A       1       5       33
  
  A       2       2       66
  A       2       3       2
  A       2       4       199
  A       2       10      319
  
  B       1       4       290
  B       1       5       188
  B       1       6       573
  B       1       9       122
  </code></pre>
  
  <p>Desired Data:</p>
  
  <pre><code>group   type    index   vol
  A       1       1       200
  A       1       2       244
  A       1       3       0
  A       1       4       0
  A       1       5       33
  
  A       2       1       0
  A       2       2       66
  A       2       3       2
  A       2       4       199
  A       2       5       0
  A       2       6       0
  A       2       7       0
  A       2       8       0
  A       2       9       0
  A       2       10      319
  
  B       1       1       0
  B       1       2       0
  B       1       3       0
  B       1       4       290
  B       1       5       188
  B       1       6       573
  B       1       7       0
  B       1       8       0
  B       1       9       122
  </code></pre>
  
  <p>I've just added in spaces between the partitions for clarity.</p>
  
  <p>Hope you can help out!</p>