Html reports

There are many ways, how to generate html pages as output of a crunch web service. However, with the RMarkdown and knitr packages, you have a powerful mechanism available that makes report generation most convenient.

= html reports with knitr (and markdown) =

To deliver a nice html report that is created by executing its embedded R code and sending along the generated images, you can use knitr markdown templates. Just create a file report-demo.Rmw (or demo.rmw) in your public/services/ folder, and it will be knitted together into one html page and delivered, whenever the url of the service is called.

This is an example of using **knitr** with extended markdown (e.g.  [GFM](http://github.github.com/github-flavored-markdown/)). Note you should set the graphical device to create images that can be displayed in the web browser, e.g. `dev = 'png'` (it is the   default for markdown output) works but `'pdf'` does not. Now we write some code chunks in this markdown file: ```{r} ## a simple calculator 1+1  ## boring random numbers set.seed(123) rnorm(5) ```  We can also produce plots ```{r md-cars, message=FALSE} library(ggplot2) qplot(hp, mpg, data=mtcars)+geom_smooth ggpcp(mtcars) + geom_line ```  So **knitr** is ready with GitHub with a single markdown file.

Thanks go to Xie Yihui and Fridolin Wild for making this possible on crunch.