[R] How to make a Latex table using R
Duncan Murdoch
murdoch.duncan at gmail.com
Thu May 15 16:47:24 CEST 2014
On 15/05/2014 9:46 AM, Liao, Hongsheng wrote:
> http://cran.r-project.org/web/packages/xtable/vignettes/xtableGallery.pdf
>
> I am trying to learn how to make a Latex table using R from the link above. However, instead of a Latex table as showed in the link, the R codes from the link generate actual Latex codes as follows:
>
> % latex table generated in R 3.1.0 by xtable 1.7-3 package
> % Thu May 15 09:21:18 2014
> \begin{tabular}{rrlllr}
> \hline
> & grade & sex & disadvg & ethnicty & tlimth \\
> \hline
> 1 & 6 & M & YES & HISPANIC & 43 \\
> 2 & 7 & M & NO & BLACK & 88 \\
> 3 & 5 & F & YES & HISPANIC & 34 \\
> 4 & 3 & M & YES & HISPANIC & 65 \\
> 5 & 8 & M & YES & WHITE & 75 \\
> 6 & 5 & M & NO & BLACK & 74 \\
> 7 & 8 & F & YES & HISPANIC & 72 \\
> 8 & 4 & M & YES & BLACK & 79 \\
> 9 & 6 & M & NO & WHITE & 88 \\
> 10 & 7 & M & YES & HISPANIC & 87 \\
> \hline
> \end{tabular}
>
> I have TeX Live 2013 installed in my computer. It doesn't help, either. Should I need some kind of connection (software or codes) between R and Latex? Thanks.
The xtable package produces LaTeX code to insert into a LaTeX document.
You need to cut and paste it into your document,
or use Sweave or knitr to insert it automatically. A minimal LaTeX
document might look like this:
\documentclass{article}
\begin{document}
Insert the code here
\end{document}
You would save that in a file with a file extension .tex, and run latex
or pdflatex on it. To do the latter you can run those programs from the
command line, or from varous editors, e.g. TeXWorks.
Duncan Murdoch
More information about the R-help
mailing list