[R] xtable() with booktabs option problem

John Kane jrkrideau at inbox.com
Fri May 24 21:48:00 CEST 2013


i knew it was something stunningly stupid.  Thanks a lot.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: marc_schwartz at me.com
> Sent: Fri, 24 May 2013 14:41:52 -0500
> To: jrkrideau at inbox.com
> Subject: Re: [R] xtable() with booktabs option problem
> 
> On May 24, 2013, at 2:36 PM, John Kane <jrkrideau at inbox.com> wrote:
> 
>> I could have sworn that yesterday xtable(file, booktabs = TRUE) was
>> giving me toprule , midrule and bottomrule outout. Today :
>> 
>> library(xtable)
>> aa  <- table( sample(letters[1:9], 100, replace = TRUE))
>>  xtable(aa,
>>         booktabs = TRUE)
>> gives me
>> 
>> \begin{table}[ht]
>> \centering
>> \begin{tabular}{rr}
>>  \hline
>> & V1 \\
>>  \hline
>> a &  15 \\
>>  b &  11 \\
>>  c &  13 \\
>>  d &  14 \\
>>  e &  10 \\
>>  f &  12 \\
>>  g &  10 \\
>>  h &   6 \\
>>  i &   9 \\
>>   \hline
>> \end{tabular}
>> \end{table}
>> 
>> What stunningly stupid thing am I doing?
>> 
>> John Kane
>> Kingston ON Canada
> 
> 
> John,
> 
> The 'booktabs' argument is for print.xtable(), not xtable(). Easy
> mistake.
> 
> Thus:
> 
>> print(xtable(aa), booktabs = TRUE)
> % latex table generated in R 3.0.1 by xtable 1.7-1 package
> % Fri May 24 14:40:07 2013
> \begin{table}[ht]
> \centering
> \begin{tabular}{rr}
>   \toprule
>  & V1 \\
>   \midrule
> a &   9 \\
>   b &   8 \\
>   c &  17 \\
>   d &   9 \\
>   e &   7 \\
>   f &  16 \\
>   g &  13 \\
>   h &  10 \\
>   i &  11 \\
>    \bottomrule
> \end{tabular}
> \end{table}
> 
> 
> Regards,
> 
> Marc Schwartz

____________________________________________________________
FREE 3D MARINE AQUARIUM SCREENSAVER - Watch dolphins, sharks & orcas on your desktop!



More information about the R-help mailing list