Creating beautiful reports from R with knitr
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.
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
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.