Publication Quality Output

Compared with SAS and SPSS, R's ability to output results for publication quality reports is somewhat rudimentary (although this is evolving).

The R2HTML package lets you output text, tables, and graphs in HTML format. Here is a sample session, followed by an explanation.

# Sample Session
library(R2HTML)
HTMLStart(outdir="c:/mydir", file="myreport",
  extension="html", echo=FALSE, HTMLframe=TRUE)
HTML.title("My Report", HR=1)

HTML.title("Description of my data", HR=3)
summary(mydata)

HTMLhr()

HTML.title("X Y Scatter Plot", HR=2)
plot(mydata$y~mydata$x)
HTMLplot()

HTMLStop()

Once you invoke HTMLStart( ), the prompt will change to HTML> until you end with HTMLStop().

The echo=TRUE option copies commands to the same file as the output.

HTMLframe=TRUE creates framed output, with commands in the left frame, linked to output in the right frame. By default, a CSS file named R2HTML.css controlling page look and feel is output to the same directory. Optionally, you can include a CSSFile= option to use your own formatting file.

Use HTML.title() to annotate the output. The HR option refers to HTML title types (H1, H2, H3, etc.) . The default is HR=2.

HTMLhr() creates a horizontal rule.

Since several interactive commands may be necessary to create a finished graph, invoke the HTMLplot() function when each graph is ready to output.

The RNews article The R2HTML Package has more complex examples using titles, annotations, header and footer files, and cascading style sheets.

Other Options

The R Markdown Package from R Studio supports dozens of static and dynamic output formats including HTML, PDF, MS Word, scientific articles, websites, and more. (To practice R Markdown, try this tutorial taught by Garrett Grolemund, Data Scientist for R Studio.)

Sweave allows you to imbed R code in LaTeX, producing attractive reports if you know that markup language.

The odfWeave package has functions that allow you to imbedd R output in Open Document Format (ODF) files. These are the types of files created by OpenOffice software.

The SWordInstaller package allows you to add R output to Microsoft Word documents.

The R2PPT provides wrappers for adding R output to Microsoft PowerPoint presentations.