Install R Kernel for JupyterLab

Posted on Dec 25, 2016 in Programming

Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives.

** Things under legendu.net/outdated are outdated technologies that the author does not plan to update any more. Please look for better alternatives. **

  1. Install JupyterLab.
wajig install python3 python3-pip python3-setuptools
sudo -H pip3 install jupyter jupyterlab
sudo jupyter serverextension enable --py jupyterlab --sys-prefix
  1. Install dev libraries required by IRKernel (or its dependent packages).
wajig install libssl-dev libcurl4-openssl-dev

If you are still on Ubuntu 14.04, you might have to force libssl to downgrade.

wajig install libssl1.0.0/trusty
  1. Upgrade R to the latest version.
wajig update && wajig install r-base-core
  1. Upgrade R packages to the latest version. Open an R sesseion using sudo and run the following statement. It takes a while, so be patient.
update.packages(ask = F, checkBuilt = T)
  1. Install IRkernel and register it.
# install dependencies packages of IRKernel
install.packages(c('repr', 'IRdisplay', 'crayon', 'pbdZMQ', 'devtools'))
# install IRkernel
devtools::install_github('IRkernel/IRkernel')
# register IRkernel
IRkernel::installspec() 

If for any reason you cannot install devtools, you can manually download IRkernel and its dependencies and install them.

install.packages('evaluate')
install.packages('uuid')
# assume you have downloaded IRkernel-0.7.1.tar.gz
install.packages('IRkernel-0.7.1.tar.gz')
  1. Configure JupyterLab. First, run the following command to generate a configuration file for JupyterLab.
jupyter lab --generate-config

Second, edit the configuration file as neede. - ip - browser - working directory

  1. Make sure that the directory ~/.local/share/jupyter and its subcontents belogn to you rather than root. If they belong to root then change the own to you by running the following command.
sudo chown -R username:usergroup ~/.local/share/jupyter
  1. Start JupyterLab.
nohup jupyter lab &

Issues

  1. Matrices are not displayed correctly. They are shown as vectors instead. However, data frames are displayed correctly.

  2. flush.console does not work well.

  3. .Last.value retrieves the return value of the last expression in R. It is not working in Jupyter 0.7 or older.

  4. IRKernel does not implement magics currently.