Monday, August 22, 2016

Run R in Jupyter Notebook on Ubuntu 16.04

R is a language and environment for statistical computing and graphics. It is a GNU project which is similar to the S language and environment which was developed at Bell Laboratories. R provides a wide variety of statistical (linear and nonlinear modelling, classical statistical tests, time-series analysis, classification, clustering, …) and graphical techniques, and is highly extensible.

You can find more information of R language on this link. R has its own IDE called RStudio which provide you with Matlab like environment for running R, and it also provide a Web IDE.

using Jupyter Notebook as R interface is an alternative to the RStudio, its fairly easy to setup and activated, we will discuss in depth about it in this post


We will use IRKernel as an interface between Jupyter and R, it is an open source project hosted on github.

Prerequisite

IRKernel will need R devtools package to compile, and it need libcurl and libssl library in order to run, so first we install it
sudo apt-get install libcurl4-openssl-dev libssl-dev

after that enter R console using
sudo R

and enter the following commands
update.packages() 
install.packages(c('repr', 'IRdisplay', 'evaluate', 'crayon', 'pbdZMQ', 'devtools', 'uuid', 'digest'))
devtools::install_github('IRkernel/IRkernel')
first we will update all R package information, then followed by installing the necessary components, then finally we install the IRKernel itself using the devtools that we just install previously


Activate R for Jupyter

then we can activate R for Jupyter Notebook using this command
IRkernel::installspec(user = FALSE)
user = FALSE means that IRKernel will be activated for all user

Using R in Jupyter Notebook

Thats it, its a very simple installation, and now you can enter your Jupyter Notebook and you will see an addition the the language that we can use



and then you can put any R code on the notebook and run it



No comments :

Post a Comment