title: Handling Latex backslashes in xtable
body: <p>I have a table that includes the following column:</p>
  
  <pre><code> mytable &lt;- data.frame(beta_0 = c(1,2,3)
  </code></pre>
  
  <p>What I want to do is output a table with a column header in latex markup, e.g. <code>$\beta_0$</code></p>
  
  <p>However, I can not seem to figure out how to output the "$\beta_0$" using <code>print.xtable</code>:</p>
  
  <pre><code>colnames(mytable) &lt;- "$\beta_0$"
  library(xtable)
  print(xtable(mytable), include.rownames = F)
  </code></pre>
  
  <p>returns a column header of </p>
  
  <pre><code>\eta\_0\$
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>$\beta_0$
  </code></pre>
  
  <p>I presume that the answer is the "sanitize.colnames.function" argument to <code>print.xtable</code>, but it is not obvious to me how to use this, and <code>?print.xtable</code> provides no examples.</p>
  
  <p>Specifically, I would like to output a latex table like:</p>
  
  <pre><code>\begin{table}[ht]
   \begin{center}
    \begin{tabular}{r}
      \hline
      $\beta_0$ \\ 
      \hline
      1.00 \\ 
      2.00 \\ 
      3.00 \\ 
      \hline
    \end{tabular}
   \end{center}
  \end{table}
  </code></pre>