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

Stefan Grosse singularitaet at gmx.net
Wed Jun 20 12:20:37 CEST 2007


It would be helpfull if you would state what exactly you did expect.

As improvements you could reduce the digits, see  ?xtable

-------- Original Message  --------
Subject: [R] "xtable" results doesn't correspond to data.frame
From: Vumani Dlamini <dvumani at hotmail.com>
To: r-help at stat.math.ethz.ch
Date: 20.06.2007 11:20
> 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.
>
>
>



More information about the R-help mailing list