[R] Tabular output: from R to Excel or HTML

Tobias Verbeke tobias.verbeke at telenet.be
Tue Dec 23 06:41:31 CET 2008


Hi Stavros,

> What is the equivalent for formatted tabular output of the various very
> sophisticated plotting tools in R (plot, lattice, ggplot2)?

For the tabulation itself the reshape package by Hadley Wickham might be 
a handy tool:

http://had.co.nz/reshape/

> In particular, I'd like to be able to produce formatted Excel spreadsheets
> (using color, fonts, borders, etc. -- probably via Excel XML) and formatted
> HTML tables (ideally through a format-independent interface), and preview
> them using commands within R, just as I would do with R graphics.  The
> reason I'd like to produce Excel or HTML rather than (say) TeX or PDF is to
> make it easy for the readers of my results to manipulate them in their own
> environments (usually Excel). There are various papers on the R-project.org
> website related to this topic, but I haven't been able to find any
> particular package supporting this functionality.  I have found information
> on importing from Excel, calling R functions from Excel, calling COM
> interfaces from R, writing unformatted (CSV) data to Excel, etc., but not on
> producing nicely-formatted tabular output.
> 
> I wouldn't have too much trouble putting together something quick-and-dirty
> to produce HTML tables, but if someone's already done it well, I'd rather
> take advantage of their work.  I also don't know enough about COM to do
> something as simple as to cause my HTML to display in a browser window or my
> XMLSS in Excel....

For the HTML part of your question, you can have a look at

- hwriter
- R2HTML

Both packages are on CRAN. See also

http://www.ebi.ac.uk/~gpau/hwriter/

HTH,
Tobias



More information about the R-help mailing list