Last data update: 2014.03.03

R: Graphically export objects to LaTeX or HTML
RcmdrPlugin.Export-packageR Documentation

Graphically export objects to LaTeX or HTML

Description

The package provides facilities to graphically export Rcmdr output to LaTeX or HTML code.

Details

The package is designed to assist in exporting Rcmdr output (or other objects printed in Rcmdr) to formats other than ASCII text, and provide R novices with an easy-to-use, easy-to-access reference on exporting R objects to formats suitable for publication. At the moment, it is a graphical front-end to xtable and latex and can export various R objects to LaTeX or HTML.

In the case of LaTeX, the printed output can be used in two ways. Taking a static approach, one can copy the generated LaTeX code and paste directly into a LaTeX document, or within an ERT inset of a LyX [1] document. If the code is exported to a .tex file, one may insert it as an external file in LyX.

A more dynamic approach consists in creating Sweave documents, which combine LaTeX and R code. In this case, one may copy the generated R code and paste into code chunks in the Sweave document. Learning Sweave is considerably trivial compared to learning R, so don't let yourself intimidated! Although standard usage of Sweave requires knowledge of LaTeX, one can readily use LyX to create Sweave documents [2][3], thus avoiding the burden of (properly) learning LaTeX. For this particular usage, the plug-in can be seen as a reference guide for retrieving (or learning) the correct syntax to exporting objects.

Inserting the exported HTML code into conventional word-processing programmes (MS Word, OpenOffice Writer, AbiWord, etc.) can get trickier, but several approaches are possible. The HTML code can, of course, be readily copied and pasted into the source of an HTML document (for example, in Mozilla SeaMonkey Composer). This also works for an HTML document developed in OpenOffice Writer/Web, which subsequently can be exported to .odt.

It is possible export the R object to an .html file. Then, one could insert the file in an OpenOffice Writer or MS Word document, with a resulting table that could be easily formatted. When working with OpenOffice, MS Word, AbiWord or Gnumeric, one can also open the .html document, then copy and paste the table into the desired document. This approach combined with the append argument is particularly useful when exporting many objects.

For more information concerning exporting R output please see this page [4] by Frank Harrell.

Developing the plug-in became possible when John Fox, the author of Rcmdr, implemented the popOutput() function. The function keeps a stack of the last several objects printed in Rcmdr, and allows to retrieve them following a "First In, First Out" paradigm. Thus, the last printed object would also be the first one retrieved. This also means that objects available for export can be displayed only one at a time; one should reinitialise the dialogue for each subsequent object. Once the dialogue is initialised, pressing "Cancel" removes the object from the stack. The length of the stack can be controlled via Rcmdr options. Please note that Rcmdr.Export is limited to handling objects printed within Rcmdr; consequently, the plug-in will not retrieve objects printed in the underlying R console.

On a final note, please contact me should you spot a bug, want to request a feature or know how to work around the issues listed in LIMITATIONS. I will also be happy to receive feedback on the present documentation.

Author(s)

Liviu Andronic landronimirc@gmail.com

References

[1] http://www.lyx.org/ – A GUI for LaTeX, similar to conventional word-processing programmes
[2] http://cran.r-project.org/doc/Rnews/Rnews_2008-1.pdfUsing Sweave with LyX, Rnews article by Gregor Gorjanc
[3] http://gregor.gorjanc.googlepages.com/lyx-sweave – Files needed to configure Sweave and LyX
[4] http://biostat.mc.vanderbilt.edu/SweaveConvert – Converting Documents Produced by Sweave

See Also

Rcmdr, xtable, latex, Sweave

Examples

## Not run: 
   ## start R
   library(RcmdrPlugin.Export)  ## loads Rcmdr and the plug-in

## End(Not run)

Results