[R] Miss lines in LaTex code generated by function xtable in R
Duncan Mackay
dulcalma at bigpond.com
Fri May 16 06:35:17 CEST 2014
Hi
If print gives you trouble try
cat("\\end{document}\n\n")
Regards
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New England
Armidale NSW 2351
Email: home: mackay at northnet.com.au
-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of David Winsemius
Sent: Friday, 16 May 2014 07:09
To: Liao, Hongsheng
Cc: r-help at r-project.org
Subject: Re: [R] Miss lines in LaTex code generated by function xtable in R
On May 15, 2014, at 1:30 PM, Liao, Hongsheng 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.
>
Just use paste(). Note that the help page for ?print.xtable says: "Note that
the function also (invisibly) returns a character vector of the results
(which can be helpful for post-processing). "
--
David.
>
> % 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.
David Winsemius
Alameda, CA, USA
______________________________________________
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