[R] xtable - print - suppress output

Thomas Lumley tlumley at u.washington.edu
Thu Sep 24 16:20:07 CEST 2009


On Mon, 21 Sep 2009, David Winsemius wrote:

>
> On Sep 21, 2009, at 5:52 PM, Martin Batholdy wrote:
>> 
>> I use xtable to convert data.frames to html tables.
>> But when I use the print-command I always get the whole output printed
>> even if I just want to save the html table into a variable;
>> 
>> table <- print(xtable(CERAT), type="html")
>> 
>> 
>> How can I suppress that output is printed?
>
> Perhaps by diverting it somewhere else? (after the example in xtable's help 
> page)
>
> capture.output(print(tli.table, type="html"), file="HTout.html")
>
> R is not an HTML editor, so it would seem less than intuitive to send it to a 
> character variable. It would not work to assign the value of capture.output 
> since that is an invisible NULL.
>

If that were true, capture.output() would be pretty useless.  The returned value is NULL if the file= argument is specified, otherwise it is the captured output.

          -thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle




More information about the R-help mailing list