How to create PDF reports with R

December 1, 2010
By

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

Sweave is a literate programming system included with R. It makes it possible to create a PDF document containing not just text, but also tables and charts generated from R. The process is automated, so once you've created an Sweave document (which includes both LaTeX text markup and R commands), you can create the formatted text and insert the tables and charts (based on the latest data you have) into the PDF at the appropriate places in a single step.

Sweave can be a little daunting to get started with, but Jeromy Anglim has created three tutorials to get you going. Tutorial 1 shows how to make a document based on data stored in a database. Tutorial 2 shows how to make a series of polished PDF reports in batch mode. And Tutorial 3 shows how to incorporate user input to create "parameterized" reports. Jeromy provides all the source code to recreate the reports and plenty of practical tips (how to use "make", for example), so if you follow along you'll soon be able to automate reports containing tables like this:

Sweave-table

and embedded graphics like this:

Sweave-graphics

Be aware though that Sweave doesn't solve every problem: see this list of top 10 annoyances with Sweave from Mario Pineda-Krch.

Jeromy Anglim: Sweave Tutorial 3: Console Input and Output - Multiple Choice Test Analysis

 

 

To leave a comment for the author, please follow the link and comment on his blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: ,

Comments are closed.