Skip to content
Prev 333766 / 398506 Next

xtable: custom row.names, move caption to top

UPDATE:
Now including the LaTeX math formatting

saxtab <- t( as.data.frame( addmargins( Saxony ) ) )
rownames( saxtab ) <- c( "Males ($k$)", "Families ($n_k$)" )
saxtab <- xtable( saxtab, digits = 0,
     caption = "Number of male children in 6115 Saxony families of size 12",
     align = "l|rrrrrrrrrrrrrr" )
print( saxtab, caption.placement = "top", include.colnames = FALSE, 
     hline.after = c( NULL, 0, nrow( saxtab ) ),
     sanitize.text.function = function(x) { x } )

% latex table generated in R 3.0.2 by xtable 1.7-1 package
% Wed Nov 27 18:16:47 2013
\begin{table}[ht]
\centering
\caption{Number of male children in 6115 Saxony families of size 12} 
\begin{tabular}{l|rrrrrrrrrrrrrr}
   \hline
Males ($k$) & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 & 12 & Sum \\ 
  Families ($n_k$) &    3 &   24 &  104 &  286 &  670 & 1033 & 1343 & 1112 &  829 &  478 &  181 &   45 &    7 & 6115 \\ 
   \hline
\end{tabular}
\end{table}
On Wednesday 27 November 2013 17:43:30 Rainer Schuermann wrote: