[R] latex(test, collabel=) returns wrong latex code?

Simon Kiss sjkiss at gmail.com
Fri Mar 15 20:33:25 CET 2013


Hello:
I'm working with a 2-dimensional table that looks sort of like test below.
I'm trying to produce latex code that will add dimension names for both the rows and the columns.
In using the following code, latex chokes when I include collabel='Vote' but it's fine without it.

The code below prouces the latex code further below.  I'm confused by this, because it looks like it's creating two bits of text for each instance of \multicolumn.  Is that really allowed in \multicolumn?
Could someone clarify?
Thank you!
Yours, SJK


library(Hmisc)
test<-as.table(matrix(c(50,50,50,50), ncol=2))
latex(test, rowlabel='Gender',collabel='Vote', file='')

% latex.default(test, rowlabel = "Gender", collabel = "vote", file = "") 
%
\begin{table}[!tbp]
\begin{center}
\begin{tabular}{lrr}
\hline\hline
\multicolumn{1}{l}{Gender}&\multicolumn{1}{vote}{A}&\multicolumn{1}{l}{B}\tabularnewline
\hline
A&$50$&$50$\tabularnewline
B&$50$&$50$\tabularnewline
\hline
\end{tabular}
\end{center}
\end{table}
*********************************
Simon J. Kiss, PhD
Assistant Professor, Wilfrid Laurier University
73 George Street
Brantford, Ontario, Canada
N3T 2C9
Cell: +1 905 746 7606

Please avoid sending me Word, PowerPoint or Excel attachments. Sending these documents puts pressure on many people to use Microsoft software and helps to deny them any other choice. In effect, you become a buttress of the Microsoft monopoly.

To convert to plain text choose Text Only or Text Document as the Save As Type.  Your computer may also have a program to convert to PDF format. Select File, then Print. Scroll through available printers and select the PDF converter. Click on the Print button and enter a name for the PDF file when requested.



More information about the R-help mailing list