[R] "xtable" results doesn't correspond to data.frame

From: Vumani Dlamini <dvumani_at_hotmail.com>
Date: Wed, 20 Jun 2007 09:20:01 +0000


Dear useRs,
Am trying to use xtable on the following data.frame and I don't get what I expect:

example.table <- data.frame(rbind(

    c("Gender"," "," "," "),
    cbind(rep(" ",2),c("Male","Female"),c(3.0,4.0),c(3/7,4/7)) ))
colnames(example.table) <- c(" "," ","number of patients","%") example.xtable <- xtable(example.table)
print.xtable(example.xtable, include.rownames=FALSE)

I can seem to get latex output which corresponds to the data.frame which is,
\begin{table}[ht]
\begin{center}
\begin{tabular}{llll}
  \hline
  & & number of patients & \% \\
  \hline
Gender & & & \\

    & Male & 3 & 0.428571428571429 \\
    & Female & 4 & 0.571428571428571 \\    \hline
\end{tabular}
\end{center}
\end{table}



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Wed 20 Jun 2007 - 09:33:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 20 Jun 2007 - 11:32:14 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.