Creating PDFs and websites with the "knitr" package

November 27, 2012
By

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

Just a fast note: I came across the R-package "knitr" which enables you to generate PDF files by mixing LaTeX and R code in one document. The result looks very nice and is great to create documentations, manuals and so on. I find knitr much easier to use than the quite popular Sweave (but I guess this has to do with personal preferences). In fact, knitr uses Sweave and expands it.

Also, you can create HTML files using R Markdown documents. Just imagine you write an article or create a website with statistical analyses or programming stuff in R. If you use the knitr package (which is, by the way, perfectly integrated into RStudio), you just run your LaTeX/R or HTML/R document as soon as you get new data or change little things and the whole document is automatically updated (including all plots, tables and so on).

Here is a very small example (in German), what this looks like. Hopefully, I will find the time and the reason to use this package within this blog...

Example: PDF
Example: HTML (R Markdown)

Have fun using knitr... or just shake your head in disbelief, why anyone would want to do such stuff :)

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

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...

Comments are closed.