How to Set Up an R Environment in JupyterLab

R is available in JupyterLab by activating the environment via the anaconda_Rcpu module. R will run on the CPU cores (not GPU enabled).

  1. Start a new Jupyter Lab session in Open OnDemand.

  2. In the JupyterLab Launcher, start a new Terminal session.

    JupyterLab Launcher window with the Terminal button highlighted.
  3. If you are automatically launching a Conda environment in your default shell setup, deactivate it.

    $ conda deactivate
    
  4. Load the R environment.

    $ module load anaconda3_Rcpu
    
  5. Launch R.

    $ R
    
  6. You should now be in an R session (your terminal prompt will change from $ to >). Inside the R session, run IRkernel::installspec().

    > IRkernel::installspec()
    
  7. Quit R.

    > q()
    
  8. Close the Terminal window in JupyterLab. That should return you to the JupyterLab Launcher (if it doesn’t, open a new Launcher window).

  9. Reload the web page containing the Launcher. Options for an R notebook and console should be available.

    JupyterLab launcher window with R options.
  10. Open an R notebook (or console) and proceed to use R.

    Example of using R in a Jupyter notebook.