[R] help with the xtable package

Erik Iverson eriki at ccbr.umn.edu
Fri Jul 2 06:08:39 CEST 2010


Changbin Du wrote:
> HI, Dear R community,
> 
> I am using the xtable to create the table, but how can I see the table?
> 
> The following is the codes I used:
> 
>> data(tli)
>>  tli.table <- xtable(tli[1:10, ])
>>  digits(tli.table)[c(2, 6)] <- 0
>>  print(tli.table, floating = FALSE)
> % latex table generated in R 2.11.0 by xtable 1.5-6 package
> % Thu Jul  1 20:43:43 2010
> \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}
> 

You're trying to generate a LaTeX table, right?

Hopefully, since this function is producing LaTeX code for you.

You need to construct a wrapper LaTeX document that includes the code output. 
You can write the code generated to disk using the ?print.xtable function, and 
its file argument.



More information about the R-help mailing list