1. Install IRkernel.

Begin by starting `R`; the default on the CZ and RZ is `/usr/bin/R` and then install `IRkernel` with `install.packages('IRkernel')`:

janeh@rzslic4:~/.local/share/jupyter/kernels$ R


R version 3.6.0 (2019-04-26) -- "Planting of a Tree"

Copyright (C) 2019 The R Foundation for Statistical Computing

Platform: x86_64-redhat-linux-gnu (64-bit)


R is free software and comes with ABSOLUTELY NO WARRANTY.

You are welcome to redistribute it under certain conditions.

Type 'license()' or 'licence()' for distribution details.


R is a collaborative project with many contributors.

Type 'contributors()' for more information and

'citation()' on how to cite R or R packages in publications.


Type 'demo()' for some demos, 'help()' for on-line help, or

'help.start()' for an HTML browser interface to help.

Type 'q()' to quit R.


> install.packages('IRkernel')

Installing package into '/usr/lib64/R/library'

(as 'lib' is unspecified)

Warning in install.packages("IRkernel") :

  'lib = "/usr/lib64/R/library"' is not writable

Would you like to use a personal library instead? (yes/No/cancel) n

Error in install.packages("IRkernel") : unable to install packages

> install.packages('IRkernel')

Installing package into '/usr/lib64/R/library'

(as 'lib' is unspecified)

Warning in install.packages("IRkernel") :

  'lib = "/usr/lib64/R/library"' is not writable

Would you like to use a personal library instead? (yes/No/cancel) y

Would you like to create a personal library

'~/R/x86_64-redhat-linux-gnu-library/3.6'

to install packages into? (yes/No/cancel) y

--- Please select a CRAN mirror for use in this session ---

I chose "75" as my CRAN mirror. A series of downloading/installing messages then followed, terminating with

Successful IRkernel install

* installing *source* package 'IRkernel' ...

** package 'IRkernel' successfully unpacked and MD5 sums checked

** using staged installation

** R

** inst

** byte-compile and prepare package for lazy loading

** help

*** installing help indices

  converting help for package 'IRkernel'

    finding HTML links ... done

    Comm-class                              html

    CommManager-class                       html

    IRkernel-package                        html

    comm_manager                            html

    installspec                             html

    log                                     html

    main                                    html

** building package indices

** testing if installed package can be loaded from temporary location

** testing if installed package can be loaded from final location

** testing if installed package keeps a record of temporary installation path

* DONE (IRkernel)

The downloaded source packages are in

'/tmp/janeh/Rtmp9uEWd6/downloaded_packages'

2. Create `kernel.json`
Create `~/.local/share/jupyter/kernels/R` and `~/.local/share/jupyter/kernels/R/kernel.json`, populating `kernel.json` with

{"argv": ["/usr/bin/R", "--quiet", "-e", "IRkernel::main()", "--args", "{connection_file}"],

 "display_name":"test R",

 "language":"R"

}

You can, of course, change the display name to whatever you like and also use a different R binary in place of the default `/usr/bin/R`, if you like.

3. Sign in to JupyterHub and find R kernel

Log in to JupyterHub and you will see your display name, e.g. “test R”, as an available kernel when you try to start a new notebook.