This notebook was created using vanilla IPython notebook with Python extension rpy2 installed. Once installed and set up, this interface is invoked like so:
ipython notebook
What follows is a short notebook that can be used to test your own setup.
Former extension rmagic
is part of rpy2 as of rpy2 2.4. Many online tutorials still use the old way of loading rmagic (%load_ext rmagic
), but the current correct method is used below (%load_ext rpy2.ipython
). The functionality is still referred to in this document as Rmagic because, well, it's snazzier than "rpy2 IPython magic integration" and it's more easily searched.
In [1]:
%load_ext rpy2.ipython
In [2]:
%R library(ggplot2)
Out[2]:
In [3]:
%R print(head(iris))
In [4]:
%%R -w 800 -h 600 -u px
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point() + theme_bw()