title: R:CrossTable- How to print frequencies for total row and column observations with xtable?
body: <p>I produced a cross table with the <code>CrossTable</code> command from the <code>gmodels</code> package such as:</p>
  
  <pre><code>library(gmodels)
  library(descr)
  a&lt;-CrossTable(mtcars$cyl,mtcars$gear,prop.chisq = FALSE)
  </code></pre>
  
  <p>If I create a table for LaTex using xtable, the frequencies for row totals (last column) and column totals (last row) are missing. However, the total counts are there.</p>
  
  <p>I used:</p>
  
  <pre><code>print(xtable(a,digits=3))
  </code></pre>
  
  <p>to achieve this. How do I get these values in as well?</p>
  
  <p>Thanks for your support.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Here an example of the output:</p>
  
  <blockquote>
    <p>a</p>
  </blockquote>
  
  <pre><code>===========================================
            mtcars$gear
  mtcars$cyl        3       4       5   Total
  -------------------------------------------
  4                 1       8       2      11
                0.091   0.727   0.182   **0.344**
                0.067   0.667   0.400        
                0.031   0.250   0.062        
  -------------------------------------------
  6                 2       4       1       7
                0.286   0.571   0.143   **0.219**
                0.133   0.333   0.200        
                0.062   0.125   0.031        
  -------------------------------------------
  8                12       0       2      14
                0.857   0.000   0.143   **0.438**
                0.800   0.000   0.400        
                0.375   0.000   0.062        
  -------------------------------------------
  Total            15      12       5      32
                **0.469**   **0.375**   **0.156**
  ===========================================
  </code></pre>
  
  <p>I highlighted the missing values after <code>xtable</code> conversion with <code>*</code>. But when I have it converted to Tex with <code>print</code> it looks like:</p>
  
  <pre><code>\begin{table}[ht]
  \centering
  \begin{tabular}{llrrrr}
    \hline
   &amp; mtcars\$cyl &amp; 3 &amp; 4 &amp; 5 &amp; Total \\ 
    \hline
  1 &amp; 4 &amp; 1 &amp; 8 &amp; 2 &amp; 11 \\ 
    2 &amp;  &amp; 0.091 &amp; 0.727 &amp; 0.182 &amp;  \\ 
   3 &amp;  &amp; 0.067 &amp; 0.667 &amp; 0.400 &amp;  \\ 
   4 &amp;  &amp; 0.031 &amp; 0.250 &amp; 0.062 &amp;  \\ 
   5 &amp; 6 &amp; 2 &amp; 4 &amp; 1 &amp; 7 \\ 
   6 &amp;  &amp; 0.286 &amp; 0.571 &amp; 0.143 &amp;  \\ 
   7 &amp;  &amp; 0.133 &amp; 0.333 &amp; 0.200 &amp;  \\ 
   8 &amp;  &amp; 0.062 &amp; 0.125 &amp; 0.031 &amp;  \\ 
   9 &amp; 8 &amp; 12 &amp; 0 &amp; 2 &amp; 14 \\ 
    10 &amp;  &amp; 0.857 &amp; 0.000 &amp; 0.143 &amp;  \\ 
    11 &amp;  &amp; 0.800 &amp; 0.000 &amp; 0.400 &amp;  \\ 
    12 &amp;  &amp; 0.375 &amp; 0.000 &amp; 0.062 &amp;  \\ 
    13 &amp; Total &amp; 15 &amp; 12 &amp; 5 &amp; 32 \\ 
     \hline
  \end{tabular}
  \end{table}
  </code></pre>