[R] latex tables for 3+ dimensional tables/arrays

Michael Friendly friendly at yorku.ca
Thu Dec 2 22:54:14 CET 2010


On 12/2/2010 4:04 PM, David Winsemius wrote:
>
> ?latex  # yes I know you are aware of this but it seemed as though you 
> hadn't read its help page.
> # Attached is the output on my device from the following command:
> latexVerbatim( ftable(UCB))

Perhaps I should have been more explicit.  I can always use verbatim as 
a fall-back, but what I want is
something to produce the *latex* code to give something actually 
formatted as a latex table.

Below is
something along the lines of what I want (similar to  t(  
structable(Dept ~ Admit+Gender, UCBAdmissions)) ).
This was written *directly* from an object in SAS/IML by routines I 
wrote some time ago.  I'm looking
for an R equivalent, something that can be used in Sweave documents.

% Table berk3 written by md2tex 12Dec99
\begin{table}[htb]
  \caption{Berkeley data: 3-way table}\label{tab:berk3}
  \begin{center}
  \begin{tabular}{|c|rr|rr|}
   \hline
& \multicolumn{2}{c}{Male} & \multicolumn{2}{c|}{Female} \\ \cline{2-5}
   Dept & Admit & Reject & Admit & Reject  \\
   \hline
   A & 512 & 313 & 89 & 19 \\
   B & 353 & 207 & 17 & 8 \\
   C & 120 & 205 & 202 & 391 \\
   D & 138 & 279 & 131 & 244 \\
   E & 53 & 138 & 94 & 299 \\
   F & 22 & 351 & 24 & 317 \\
   \hline
  \end{tabular}
  \end{center}
\end{table}

-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University      Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA



More information about the R-help mailing list