How to create PDF reports with R
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.