Using R in a Jupyter/Ipython Notebook with Ubuntu
I may have mentioned it before, but I love the Jupyter Notebook. It’s the only way I come close to keeping my code and analyses organized. I’m not a huge fan of R, mostly because I’m not great at it, but I have to use it sometimes. Today was my third attempt at integrating the R kernel into the Notebook, and it took several hours. I figured it would be worthwhile to chronicle what finally worked, in case I need it later.
Here’s my setup:
Ubuntu 14.04 LTS
CPython 2.7.11
- Open the 'Ubuntu Software Center'.
- Edit -> Software Sources.
- Click the 'Other Software' tab.
- Click the 'Add' button.
- Fill in 'deb http://cran.fhcrc.org/bin/linux/ubuntu trusty/'
- Click the '+ Add Source' button.
$sudo apt-get update $sudo apt-get upgrade $sudo apt-get install r-base r-base-dev
At this point you should have a proper version of R. Next we can start working on kernel dependencies. Also from the terminal, run:
$sudo apt-get install libzmq3-dev
We’re almost done. From inside R (using either the terminal or an IDE like RStudio), run:
install.packages(c('rzmq','repr','IRkernel','IRdisplay'),
repos = c('http://irkernel.github.io/', getOption('repos')),
type = 'source')
IRkernel::installspec()
And there you go! Things should be up and running now, and you should have the option to create an R notebook: