Creating beautiful reports from R with knitr

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

People use the R language every day to create the elements of reports: tables, charts, analyses, and forecasts. But assembling all of that information into a print-ready document laid out with text can a hassle. You can cut-and-paste all of the elements into Word, but then what do you do when the data file gets updated at the last minute? (Answer: you have to re-run all the R code and go through the whole cut-and-paste process again. What a pain.) An alternative is to Sweave, but that requires having a working TeX installation, and learning how to use LaTeX.

Now there's an easier-way: Yihui Xie's knitr package. It's a similar to Sweave in that it automates the process of combining text with images, data and code generated by R, but it's easier to learn and use because you structure the document with MarkDown instead of LaTeX.

RStudio has great knitr support and the ability to publish generated documents to the cloud for sharing. Take a look at the RStudio RPubs site (and also here) for some stunning examples of documents created with knitr, like the report on integrating R and Google visualizations excerpted below.

R Google Maps
For a primer on getting started with knitr and Markdown, see the tutorial from Jeromy Anglim linked below.

Jeromy Anglim's Blog: Psychology and Statistics: Getting Started with R Markdown, knitr, and Rstudio 0.96

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

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)