Update (April 3, 2016): Since posting this a little over year ago a great deal has progressed on this front. Notably, Jupyter has moved on to 4.x, and as pointed out in the comments, you can follow specific instructions on installing the R kernel for the Jupyter notebook 4.x+ here.
Nonetheless, the information below may be useful for walking through the more basic steps needed if you are relatively new to programming or software development. It also may explain steps that are just listed as instructions in the official page. The hope is that there is value in this post, even though there are new resources for ealing with newer versions of the notebook.
Initial instructions & preliminaries
Examine the IRkernel instructions (i.e., read the README.md file). Below are a few preliminary questions that you might run up against if you are new to programming. If you are an experienced programmer and know the meaning of "terminal",
Jupyter, you may wish to skip to the section called Installing R and devtools.
- Do you know how to open a terminal window? Try pressing ⌘+space to open Spotlight (a OSX tool) and type “Terminal” into the bar that opens.
- What do you use as your terminal emulator? If the regular terminal, I would suggest downloading and installing iTerm2, it will make your life easier.
- Do you know how to use
brew? If not, read this explanation.
- This entire walkthrough will not be very useful unless you already have
python(2.7 or 3) and
IPythoninstalled. Go to the
IPythoninstallation site to set up
IPython 3are very different things.
python 3is the officially sanctioned version of
pythonwhich is contrasted often with
python 2.7which has extensive library support, but which will not be developed any further by the core
IPython 3is version of
IPythonthat was recently released.
IPythonstands for "interactive
python" and is equipped with a powerful in-browser interactive editor known as the
IPython notebook. As you might guess from the title of this walkthrough, this editor can run
R. The project has recently split into two parts
Jupyter. The details of this split have largely to do with the former focusing on
pythonspecifically with the latter focusing on language agnostic capabilities (such as the
Rkernel that we will be installing).
IPython 3.xwill be the last release of
IPythonthat includes the notebook. More information about the two projects can be found at the IPython site and the Jupyter site.
- If you already have
python, but do not have
IPython notebookinstalled, try running
pip install "ipython[notebook]".
Run R from the command line to open an R terminal, then, run the command
- If you do not have R installed, run
brew install r. Be aware — because of the number of required packages, this can take a while to finish.
- If you have R installed, but you run into issues regardless, try instead running
brew upgrade r.
- Hint: If you don’t know how to run R from the command line, but you have installed try typing
rin your bash terminal (i.e., capitalization doesn’t matter).
- If after doing this, you still cannot get
install.packages("devtools")to work after installing via brew. Go to R’s homepage and download and install the latest version from their
pkginstaller (at time of writing this is R 3.1.2).
Dealing with a common issue:
At this point if you continue with the instructions at the IRkernel github page, you may run into the issue that is discussed here regarding the lack of availability of
rzmq given the current way that
install_github works (especially since it is also absent from CRAN).
- To get this you will need to have a working version of git, which comes with the XCode command line tools and if you attempt to use
gitfrom the command line and you do not have it installed, it will prompt you to install it.
Even better would be to follow the instructions here that describe how to update git to a more recent version than that installed by Apple while moving your Apple version of git to its own separate directory.
First, check that you have basic bindings for ZeroMQ (which is what
zmqrefers to). Do not worry if it says you already have them, if you want to update them instead, just change
brew install czmq zmq
With that in place you want to recursively clone the git repository that has the relevant
rzmqbuild, which you can do by putting the following line into your terminal (which will clone it to your current working directory, which you can see by typing
git clone https://github.com/armstrtw/rzmq.git --recursive
And then without navigating to any other directory (this is key for the work around to work), `r`, and once the R terminal is running, paste the following commands:
install.packages('RCurl') library(devtools) install_local('./rzmq') install_github('IRkernel/repr') install_github('IRkernel/IRdisplay') install_github('IRkernel/IRkernel')
If you are using IPython 3 then insert the following command as well.
Payoff: Checking to make sure it works.
Go to your command line prompt once again (i.e., open a new Terminal or iTerm2 window), and run the following command:
This should open a window in your web browser of choice. If you have IPython 3 installed, in the upper right hand corner you should see menu-button that says “New ▾” (see the item pointed to in the following picture):
If everything has worked out well, click this menu-button you should see (at least) the following options:
Which means all you need to do now to run
R in a
IPython notebook is to click the letter “R”. A new window should open with an
R kernel that is ready to go.
If you’ve gotten this far, well done! Enjoy your new
Updated: 2015_20_7_1648. Thanks to Alistair Walsh, Andrew Lonsdale and johnlaudun for their comments which helped me improve this since originally posting it.
My aim with this tutorial is to make it accessible to literally anyone who can read English text and has access to OSX and the internet. This means that some of my explanations may seem rudimentary, but I find that too few instances of someone actually going through ↩
If you have another application launcher installed then this will also work. I merely assumed that people who do not know what the terminal is probably do not know that launchers exist, though I surely could be wrong. ↩
sudois an abbreviation for “substitute user do” though it is also commonly said to be an abbreviation for “super user do”. The wikipedia entry on
sudodoes a better job of explaining this than a footnote to a 3rd level indented list item ever could(see also). ↩