knitr Support in Emacs (via ESS)
The latest version of ESS now includes support for knitr. This script is no longer necessary.
During my recent switch from vim to Emacs I discovered what a wonderful tool ESS is. It was fantastic for writing Rnw documents using Sweave, but seeing as I’m currently attempting another switch, from Sweave to knitr, I wanted support for that.
After a quick look at the ESS source code, I was able to write a quick script that gives ESS support for knitr.
Installation
- Download the Emacs lisp script below.
- Store it in a useful location, I stored it in the following path:
~/.emacs.d/ess-knitr/ess-knitr.el. - Import the script in your
.emacsfile. My configuration is the following:Note: This snippet should be included after the code that loads ESS.;; Add support for knit and purl (add-to-list 'load-path "~/.emacs.d/ess-knitr/") (require 'ess-knitr)
Usage
M-n r“knit” anRnwdocument.M-n u“purl” anRnwdocument.