Home » R » Writing R vignettes in emacs org mode using ox-ravel

Writing R vignettes in emacs org mode using ox-ravel

I want to be able to write R vignettes in org-mode. Crazy, perhaps, but it has become my default way to write everything, notes on current projects, even beamer slides and papers. Now I need to write a vignette for the coloc R package, and switching to Sweave reminds me what a pain that is. So I had a play with knitr before, and liked it, but again it means learning a new markup syntax.

I have found ox-ravel, which means I can now write .org files, and export part or all to Sweave, knitr, brew, etc. I cannot stress just how fantastic this is, in allowing me to write everything in one syntax!

But setting it up required updating org-mode, because it requires the new ox export engine found in org-8. In the process, I didn’t want to break org2blog which I use to write these blog posts. Knowing this could get complicated, I documented each step here.

Updating org

I updated to org-8 using package.el in emacs.

M-x package-install RET
org RET

(org-version) still said 7.8.11 though. To use the new org-8, I needed to add


to my ~/.emacs before any org variables


Then I git cloned orgmode-accessories

git clone https://github.com/chasberry/orgmode-accessories.git

and followed the step by step instructions in ox-ravel.org in the downloaded files, moving the resulting ox-ravel.el file to somewhere in my load-path, and adding

(require 'ox-ravel)

to my .emacs

I wrote a vignette.org file which you can see at github and exporting it via org-export-dispatch to any of the number of ravel-backends appears to work well. I can generate brew, markdown, Rnw files. You can see the .Rnw on github. I also added vignettes/vignette.org to my .Rbuildignore file so it wouldn’t confuse the R package builder.


Consulting https://github.com/ptrv/org2blog/tree/org-8-support, I did

git clone -b org-8-support https://github.com/ptrv/org2blog.git

to grab a branch of org2blog that has been updated to work with org-8. I made sure the new org2blog, and not the old one, was in my emacs load-path, and everything worked out of the box!


3 thoughts on “Writing R vignettes in emacs org mode using ox-ravel

  1. Yay! I needed to contribute tutorials for bioinformatics newbies for a workshop being taught using RStudio Server.

    to walk through their first are learning converts new course but am creating lessons for new

    I live and breath in org-mode + R + ESS. ox-ravel let me compose in org and export .Rmd files for the students to walk through in RStudio Server.

    Win, Win, WIn.


    PS – I see it has not had commits in a while, yet you have remaining TODOs. Are you still actively working on improvements?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s