Intro

This notebook was created using the "fake" R kernel described here, which is essentially a patched version of Fernando Perez's original implementation. Note that this approach requires installation of the Python extension rpy2. R commands can be run directly because the rpy2.ipython extension is automatically loaded and the each code cell is automatically prepended with the Rmagic %%R. After following the setup instructions here (toward the end of the page), to run IPython Notebook with this custom "kernel" (really a profile), start the notebook with this command:

ipython notebook --profile=rkernel

What follows is a short notebook that was created under this custom profile that can be used to test your own setup.

Run some R code


In [1]:
library(ggplot2)


Use suppressPackageStartupMessages to eliminate package startup messages.

In [2]:
head(iris)


  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa

In [3]:
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point() + theme_bw()