Building a presentation, report or paper in R

[This article was first published on Quantitative thoughts » EN, 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.

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', '');

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

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.

To leave a comment for the author, please follow the link and comment on their blog: Quantitative thoughts » EN. 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)