title: Insert a row of NAs after each group of data using data.table
body: <p>I am trying to add a row of NAs after each group of data in <code>R</code>.</p>
  
  <p>A similar question has been asked earlier. <a href="https://stackoverflow.com/questions/20260458/insert-a-blank-row-after-each-group-of-data">Insert a blank row after each group of data</a>.</p>
  
  <p>The accepted answer works fine in this case too as follows.</p>
  
  <pre><code>group &lt;- c("a","b","b","c","c","c","d","d","d","d")
  xvalue &lt;- c(16:25)
  yvalue &lt;- c(1:10)
  df &lt;- data.frame(cbind(group,xvalue,yvalue))
  df_new &lt;- as.data.frame(lapply(df, as.character), stringsAsFactors = FALSE)
  head(do.call(rbind, by(df_new, df$group, rbind, NA)), -1 )
       group xvalue yvalue
  a.1      a     16      1
  a.2   &lt;NA&gt;   &lt;NA&gt;   &lt;NA&gt;
  b.2      b     17      2
  b.3      b     18      3
  b.31  &lt;NA&gt;   &lt;NA&gt;   &lt;NA&gt;
  c.4      c     19      4
  c.5      c     20      5
  c.6      c     21      6
  c.41  &lt;NA&gt;   &lt;NA&gt;   &lt;NA&gt;
  d.7      d     22      7
  d.8      d     23      8
  d.9      d     24      9
  d.10     d     25     10
  </code></pre>
  
  <p>How can I speed this up using <code>data.table</code> for a large data.frame?</p>