/knitr-jekyll

Automatically knit R Markdown documents, build them with Jekyll, and serve the website with servr locally

Primary LanguageJavaScriptMIT LicenseMIT

kntir-jekyll (with htmlwidgets)

A fork of Yihui's superb knitr-jekyll repo, tweaked to allow it to render htmlwidgets output, using some additional wrapper functions from my personal R package.

This blog-post explains the ins-and-outs of what's going on under the hood to make it all work: brendanrocks.com/htmlwidgets-knitr-jekyll.

Note: This repo stores the source for posts in thier own subdirectories (e.g. ./_source/new-post/2015-12-07-new-post.Rmd), which is purely my personal preference, but is slightly different to the original. This means that to get the blog generated/served, you might have more luck with brocks::blog_gen()/brocks::blog_serve() than the servr::jekyll() defaults.

Installation / Dependencies

R Package Dependencies

To get this repo working, you'll need the wrapper function brocks::htmlwidgets_deps in the brocks package. To render the example post featuring htmlwidgets, you'll also need those packages. Here's the lot:

# Required for the htmlwidgets wrapper functions -----------------------------
# install.packages("devtools")
devtools::install_github("brendan-r/brocks")

# For knitr-jekyll, and the htmlwidgets stuff --------------------------------
install.packages(c(
  "servr",
  "knitr",
  "metricsgraphics",
  "leaflet",
  "threejs",
  "maps"
))

This repo

Clone with git, or just download as a .zip. From there, get editing!

Getting blogging

In addition to Yihui's post on how the system works, I wrote a little guide (with a gentle introduction to static site generation) here: brendanrocks.com/blogging-with-rmarkdown-knitr-jekyll.