[R] Miss lines in LaTex code generated by function xtable in R

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Fri May 16 00:11:32 CEST 2014


Why not use knitr to build the document that the output of xtable is to be a part of?
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On May 15, 2014 1:30:59 PM PDT, "Liao, Hongsheng" <HLiao at odu.edu> wrote:
>data(tli)
> ## Demonstrate data.frame
> tli.table <- xtable(tli[1:10,])
> digits(tli.table)[c(2,6)] <- 0
> print(tli.table,floating=FALSE)
>
>I used above R code to generate Latex code as below.  However, Tex Live
>can't run the code after I code and paste it to Tex Live.  The reasons
>are: at the very beginning of the Latex code, two lines are missing:
>\documentclass[11pt]{article}
>\begin{document}
>
>At the end of the Latex code, one line is missing: \end{document}.  I
>have to type those three lines in TeX Live in order to run the code. 
>Does anyone know how to add those three lines in xtable function in R? 
>Thanks.
>
>
>% latex table generated in R 3.1.0 by xtable 1.7-3 package
>% Thu May 15 14:25:13 2014
>\begin{table}[ht]
>\centering
>\begin{tabular}{rrlllr}
>  \hline\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 \\
>  11 & 3 & M & NO & WHITE & 79 \\
>  12 & 6 & F & NO & WHITE & 84 \\
>  13 & 8 & M & NO & WHITE & 90 \\
>  14 & 5 & M & NO & WHITE & 73 \\
>  15 & 8 & F & NO & WHITE & 72 \\
>  16 & 6 & F & NO & BLACK & 82 \\
>  17 & 4 & M & NO & WHITE & 69 \\
>  18 & 3 & F & YES & HISPANIC & 17 \\
>  19 & 3 & M & NO & HISPANIC & 37 \\
>  20 & 5 & M & NO & WHITE & 70 \\
>   \hline\hline
>\end{tabular}
>\end{table}
>
>
>
>
>
>Hongsheng (Hank) Liao, PhD.
>Lab Manager
>Center for Quantitative  Fisheries Ecology
>Old Dominion University
>757-683-4571
>
>
>
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org 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