Brendan Rocks


Blogging with rmarkdown, knitr, and Jekyll


Head of Data Science @ Satmetrix

why bother?

1. because you're not as clever as you think

2. because your memory is horrible

3. exploit the kindness/boredom of experts

4. because hadley wickham told you to

If you want to give back, I think writing a blog is a great way. Many of the things that you struggle with will be common problems. Think about how to solve them well and describe your solution to others.

-- From Hadley’s Reddit AMA a few weeks ago

but isn't it difficult and/or boring?

previous options

  • Do your analysis and copy and paste the results over
    • Use a mardown-based blog-aware SSG like Jekyll, Hyde, Pelican, Hexo etc.
    • Use a GUI, like Wordpress,, etc.


  • Roll your own R based Static Site Generator!                             
    • I've done this before... Don't do this!
  • Use an R package
    • There's a few options, but none on CRAN or under active-development

thanks to yihui xie


 you can blog in two commands!

(and some dodgy wrapper functions I wrote)

  • Creates an Rmarkdown file with the neecesary boilerplate, in a new subdirectory within the blog
  • Opens the Rmarkdown file in the Rstudio editor
  • Serves an interactive live-preview of the site in the Rstudio viewer window, which updates whenever you save changes


those two commands in full

  • Rebuilds the site locally, then uploads any changes an Amazon S3 bucket (which points to this domain name). The blog post is now live on the internet!
  • This is just an R wrapper around the awscli commandline interface.

what is this black magic?

how jekyll works

how knitr-jekyll works

putting things on the internet

alias push_blog='aws s3 sync /home/br/projects/ \ s3:// --exclude "cache/*|" --delete'

Is easy withe the awscli

live demo!!

do it yourself!

1. Install R dependencies


  install.packages(c("knitr", "servr",      


2. Install Ruby & Jekyll

3. Clone or download Yihui’s knitr-jekyll repo


4. Open up knitr-jekyll/knitr-jekyll.Rproj, and get blogging!

  new_post("My first blog post!")

thank you!

For details

 see the accompanying blog postS!