How to create PDF reports with R

December 1, 2010

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:


and embedded graphics like this:


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



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.