On Mon, Sep 21, 2009 at 3:52 PM, Don MacQueen <macq@llnl.gov> wrote:

snip...


> In other words, there is no such thing as saving the html table into a
> variable. It just doesn't work that way. All that is possible is to write it
> (print it) to either the screen or a file.
>
> Which leads back to the question that one of the other responses asked ...
> what is the reason for saving it to an R object? What do you hope to
> accomplish by doing that, that you can't accomplish using print() ?
>
> Hope this helps
>
> -Don
>
>
Actually, I find myself doing this all the time with xtable output. xtable()
is a very nice piece of code and it has saved me a lot of time-- but in some
cases I have found the defaults/options available for output formatting
rather... inflexible.

The quickest solution for me has always been to capture the output of
print.xtable() as an R character vector, do some editing/splicing/tweaking
and then re-emit the code. I use a tweaked version of the print.xtable
function that omits the final print() statement (which is what causes all
the output to hit the console, or your LaTeX document or wherever else you
don't want it to go) and reorganizes the output for easy editing. You can
make your own using:

myXtable <- edit( xtable:::print.xtable )

Then replace the lines:

print(result)
return(invisible(result$text))

With:

result$text <- strsplit( result$text, '\n' )[[1]]
return( result$text )


Now, you can use

output <- myXtable( xtableObject, type = 'html' )

To capture the output as a character vector and edit it as you wish.

Hope that helps!

-Charlie

	[[alternative HTML version deleted]]


