When using Jupyter Notebooks I like to use the version of R that I use by default in RStudio and not Anconda R. To enable this I do the following:
- DO NOT install Anaconda R (assuming you have installed Anaconda)
- Using R in your terminal – on linux it is
ctrl + alt + t
simply type R on the command line
- Once in R in your terminal (not in RStudio), install IRkernel package by typing
install.packages("IRkernel")
and enter
- After IRkernel is installed enter the command:
IRkernel::installspec()
This should do the trick. Now open Jupyter Notebook or Lab and you should be able to use your default R kernel.
If you are on Windows you have to follow slightly different steps, I’ve tried to lay them down below (note I’ve only tried it on Windows 10):
- Get the path to your Window’s R. Usually it is in
C:\Program Files\R\R-3.6.0\bin
- Now go to Anaconda Prompt (you should have this if you installed Anaconda3). Just search for it on your Start Menu
- Navigate to your R path
cd C:\Program Files\R\R-3.6.0\bin
or at least mine is
- Start R in this shell by typing
R.exe
and hitting enter
- Now install IRkernel package as you would do normally -
install.packages("IRkernel")
- Once installed enter the command:
IRkernel::installspec()
That’s it. That should do the trick. Now fire up your Jupyter Notebook or Lab and you should be able to use your default system R kernel.