R trên Jupiter Notebook (Ubuntu 14.04 / 14.10 / 16.04)

Jupyter Notebook là công cụ khá mạnh của lập trình viên Python và Data Science. Nếu dùng R, Jupyter cũng cho phép ta tích hợp R kernel vào Notebook một cách dễ dàng.

Cài đặt

  1. Cài Jupyter Notebook và R
# Install Jupyter Notebook
pip install jupyter

# Install R
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/'
sudo apt-get update
sudo apt-get install r-base
  1. Cài đặt R kernel, mở R command line
root@duyetdev:~# R

R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree"
Copyright (C) 2015 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

> install.packages(c('repr', 'IRdisplay', 'crayon', 'pbdZMQ', 'devtools'))
> devtools::install_github('IRkernel/IRkernel')
> IRkernel::installspec()  # to register the kernel in the current R installation

  1. Khởi động Jupyter Notebook
jupyter notebook
  1. Tạo Notebook mới và chọn R Kernel

Tham khảo

Ngoài ra, Jupyter còn hỗ trợ rất nhiều Kernel khác do cộng đồng phát triển, xem tại đây: https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-languages

IRkernel: https://github.com/IRkernel/IRkernel