title: Adding multicolumns to my texreg output
body: <p>I want to make a table with grouped <em>columns</em> via <code>texreg</code>. I can only see options for grouped <em>rows</em> (<code>groups</code>).</p>
  
  <p>Here's an example:</p>
  
  <pre><code>set.seed(01349)
  DF &lt;- data.frame(y = rnorm(100), x1A = rnorm(100), x2A = rnorm(100),
                   x1B = rnorm(100), x2B = rnorm(100))
  regs &lt;- lapply(paste0("x", 1:2, c("A", "A", "B", "B")), function(x)
            lm(paste0("y ~ ", x), data = DF))
  </code></pre>
  
  <p>Here's as close as I can get with plain <code>texreg</code>:</p>
  
  <pre><code>texreg(regs, custom.coef.names = c("Intercept", rep("x", 4)),
         custom.model.names = c("1", "2", "1", "2"))
  </code></pre>
  
  <p>With LaTeX output:</p>
  
  <pre><code>\begin{table}
  \begin{center}
  \begin{tabular}{l c c c c }
  \hline
             &amp; 1 &amp; 2 &amp; 1 &amp; 2 \\
  \hline
  Intercept  &amp; $-0.13$  &amp; $-0.13$  &amp; $-0.11$  &amp; $-0.11$  \\
             &amp; $(0.12)$ &amp; $(0.12)$ &amp; $(0.12)$ &amp; $(0.12)$ \\
  x          &amp; $0.02$   &amp; $0.07$   &amp; $0.13$   &amp; $-0.11$  \\
             &amp; $(0.13)$ &amp; $(0.12)$ &amp; $(0.12)$ &amp; $(0.13)$ \\
  \hline
  R$^2$      &amp; 0.00     &amp; 0.00     &amp; 0.01     &amp; 0.01     \\
  Adj. R$^2$ &amp; -0.01    &amp; -0.01    &amp; 0.00     &amp; -0.00    \\
  Num. obs.  &amp; 100      &amp; 100      &amp; 100      &amp; 100      \\
  RMSE       &amp; 1.18     &amp; 1.17     &amp; 1.17     &amp; 1.17     \\
  \hline
  \multicolumn{5}{l}{\scriptsize{$^{***}p&lt;0.001$, $^{**}p&lt;0.01$, $^*p&lt;0.05$}}
  \end{tabular}
  \caption{Statistical models}
  \label{table:coefficients}
  \end{center}
  \end{table}
  </code></pre>
  
  <p>I'd prefer an extra line (highlighted with <code>%</code> comments):</p>
  
  <pre><code>\begin{table}
  \begin{center}
  \begin{tabular}{l c c c c }
  \hline
  %*************A HEADER LINE HERE*********************
   &amp; \multicolumn{2}{c}{A} &amp; \multicolumn{2}{c}{B} \\ %
  %****************************************************
             &amp; 1 &amp; 2 &amp; 1 &amp; 2 \\
  \hline
  Intercept  &amp; $-0.13$  &amp; $-0.13$  &amp; $-0.11$  &amp; $-0.11$  \\
             &amp; $(0.12)$ &amp; $(0.12)$ &amp; $(0.12)$ &amp; $(0.12)$ \\
  x          &amp; $0.02$   &amp; $0.07$   &amp; $0.13$   &amp; $-0.11$  \\
             &amp; $(0.13)$ &amp; $(0.12)$ &amp; $(0.12)$ &amp; $(0.13)$ \\
  \hline
  R$^2$      &amp; 0.00     &amp; 0.00     &amp; 0.01     &amp; 0.01     \\
  Adj. R$^2$ &amp; -0.01    &amp; -0.01    &amp; 0.00     &amp; -0.00    \\
  Num. obs.  &amp; 100      &amp; 100      &amp; 100      &amp; 100      \\
  RMSE       &amp; 1.18     &amp; 1.17     &amp; 1.17     &amp; 1.17     \\
  \hline
  \multicolumn{5}{l}{\scriptsize{$^{***}p&lt;0.001$, $^{**}p&lt;0.01$, $^*p&lt;0.05$}}
  \end{tabular}
  \caption{Statistical models}
  \label{table:coefficients}
  \end{center}
  \end{table}
  </code></pre>
  
  <p>Am I missing something, or is there no built-in way to do this?</p>
  
  <p>My workaround is:</p>
  
  <pre><code>x &lt;- capture.output(texreg(
    regs, custom.coef.names = c("Intercept", rep("x", 4)),
    custom.model.names = c("1", "2", "1", "2")))
  
  x[6] &lt;- paste0("&amp; \\multicolumn{2}{c}{A} &amp; \\multicolumn{2}{c}{B} \\\\ \n", x[6])
  
  cat(x, sep = "\n")
  </code></pre>
  
  <p>But that's obviously a bit duct-tape-y.</p>