How to Add R to Jupyter Notebook (full steps)

You can add R to Jupyter Notebook by typing the following command in the Anaconda Prompt:

conda install -c r r-irkernel

Here are the full steps to add R to Jupyter Notebook.

Steps to Add R to Jupyter Notebook

Step 1: Open the Anaconda Prompt

To start, open the Anaconda Prompt.

You’ll then see the following screen with your user name:

(base) C:\Users\Ron>

Step 2: Add R to Jupyter

Next, type/copy the following command in order to add R to Jupyter:

conda install -c r r-irkernel

The command would look like this in the Anaconda Prompt (press ENTER to proceed with the installation):

(base) C:\Users\Ron>conda install -c r r-irkernel

Next, type ‘y‘ and then press ENTER to proceed:

Proceed ([y]/n)? y

After a short period of time, your installation would be completed.

Step 3: Launch Jupyter Notebook

To launch Jupyter Notebook, first open the Anaconda Navigator.

Then, click on the button to launch Jupyter.

Step 4: Create a new Notebook

To create a new Notebook for R:

  1. First, click on ‘New‘ on the top right-hand-side of your screen
  2. Finally, select ‘R‘ from the drop-down list

Step 5: Run your Code

You can now run your desired R code.

For example, you can create a simple DataFrame in R using this syntax:

df <- data.frame(product = c('oven', 'microwave', 'toaster'),
                 price = c(850, 300, 120)

Click on ‘Run’ and you’ll get the following DataFrame:

    product price
1      oven   850
2 microwave   300
3   toaster   120

Leave a Comment