Adam T. Bradley

Posts in tag “blogging”

RMarkdown and Jekyll

While migrating my blog recently from WordPress to Jekyll, I looked for easy ways to post RMarkdown documents to my blog. I ended up developing two options of my own (available on GitHub):

jekyll.R provides two R functions to let you add posts or drafts to your Jekyll blog direct from the RStudio console, by knit()ing an .Rmarkdown document into markdown with the YAML front-matter Jekyll expects. This is probably the best option for blogs.

rmarkdown_converter.rb is a Jekyll plugin that provides an Rmarkdown converter. This lets write your posts in RMarkdown and save them in your site's _drafts or _posts directory with the extension Rmd or Rmarkdown, just like you normally post standard markdown documents.

The downside here is that changes to your R environment (you get a new computer and don't reinstall all of the packages you had before, you upgrade R and one of the packages you used to use is no longer supported, etc.) can make it impossible to build your blog (or at least some posts). It might be more useful for some non-blog sites.

This code borrows heavily from the sample converter on the Jekyll plugins documentation page and this post by Simon Elliston Ball.