Search code examples
rjupyter-notebookanacondacondabioconductor

Set Jupyter R kernel to environment version, not to system default


Today I'm setting up an R environment in Anaconda on my Linux machine. The goal is to run a specfic version of R that can handle the dependencies of a bioinformatics pipeline.

So far, I have: downloaded and installed Anaconda (v 4.5.4), and created and activated an environment for R:

conda create --name r_3.5.1
conda activate r_3.5.1

Searched for and downloaded a specific version of R and R-essentials in the activated environment:

conda search r-base
conda install -c conda-forge r=3.5.1
conda search r-essentials
conda install -c r r-essentials=3.5.1

However, when I open a jupyter-notebook while in this environment, start a new R notebook, and check the version, I'm running version 3.2.3. This old version appears to be what's in my /usr/bin/r, while the R version I want is in /home/me/anaconda3/envs/r_3.5.1

How can I specify that when I open or create a jupyter-notebook for R in a particular environment, that it opens with the specific version of R I want?


Solution

  • Opening a Jupyter notebook in the environment was not sufficient to begin using the specified version of R.

    To fix the problem, I installed jupyter while in my environment:

    conda install jupyter
    

    Then I opened a prexisting jupyter notebook that had previously been using the wrong R kernel, and ran in a cell:

    install.packages('IRkernel')
    IRkernel::installspec()
    

    and confirmed with version in a different cell that I was running the correct version.