Alicia Schep recently discovered an interesting fact about knitr: you can not only use other languages in R Markdown (Python, Julia, C++, Bash, SQL, and so on), but also actually have full control of how to run such code chunks. In other words, these “language engines” in knitr are fully customizable and extensible.
In her blog post, she expressed the surprise and joy:
After figuring out a quick way to do this, I ended up becoming interested in how knitr’s language engines work, and was pleasantly surprised by how accessible the engines are — with a few lines of code you can add a new chunk option to affect the output of a javascript chunk!
That is exactly what I expect users to discover. This fact was not documented in great detail anywhere in public, unless you read the source code. The only full documentation was in the knitr book (Dynamic Documents with R and knitr), which is unfortunately not free. Good news is that this may change in this summer.
So thanks, Alicia. I started my day in a pleasant morning.
BTW, have I mentioned how awesome Nick Strayer and Lucy D’Agostino McGowan are?
- Update on 2018-03-02
-
Colin Fay is also awesome! Thanks!