Building a Presentation, Report or Paper in R

| Comments

If you need to build a presentation, obviously you have following options:

  • Powerpoint alike presentation

  • Online engines

  • LaTex

The first two are beloved by business people and the third one is widely used in academia. The objective of the first group is shiny presentation, contrary to the second where asceticism and demand for automation are top priorities. However, if you are data scientist or any other data specialist with a need to build an automated report, then you know, that LaTex is just wrong. LaTex allows you to build a shiny presentation or outstanding paper, however it can take light years to build something useful for beginners . If you never tried LaTex here is an example of the monster - you literally have to code a document or presentation:

\title {Investment strategy}
\author {Dzidorius Martinaitis}

So, what do you do, if you need only 1% of all LaTex features and a report/document needs to be build automatically? Turns out, that HTML little brother Markdown is saving the world. Markdown(.md) source files are easy to read and easy to write and you can convert it into .html, .pdf, .docx, .tex or any other format. There are many ways to do conversion, however I use Pandoc utility. By the way this post was written in markdown in Vim and you can check the source file.

However, the nicest thing about Markdown is integration with R. You can build your report in one file, where R code would be embed in Markdown. Knitr package will help you to convert R code into Markdown simply by calling this piece of code:

knit('workshop.Rmd', '');</code>

Below you will find an excerpt of .Rmd file which is mix of R and Markdown:

<code>Get the data

Who is tweeting about #Haxogreen

```{r results=asis,comment=NA, message=FALSE}
options(xtable.type = 'html')

Plot top10 tweeters
```{r topspam, figure=TRUE,fig.cap=''}

Here is a workshop presentation which contains the example above - I built it for Haxogreen hackers camp and source code can be found on gitHub.