How to Add R to Jupyter Notebook (full steps)

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

conda install -c r r-irkernel

But just in case you were wondering, here are the full steps to add R to Jupyter Notebook from scratch.

Steps to Add R to Jupyter Notebook

Step 1: Open the Anaconda Prompt

To start, open the Anaconda Prompt:

Anaconda Prompt

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

User - Anaconda Prompt

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):

How to Add R to Jupyter Notebook

You’ll eventually see the following:

How to Add R to Jupyter Notebook

Type ‘y‘ and then press ENTER to proceed:

Add R to Jupyter Notebook

After a short period of time your installation will be completed:

Complete installation

Step 3: Launch Jupyter Notebook

To launch Jupyter Notebook, first open the Anaconda Navigator:

Anaconda Navigator

Then, click on the button to launch Jupyter:

How to Add R to Jupyter Notebook

Next, click on ‘New’ on the top right-hand-side of your screen:

New Session

Finally, select ‘R’ from the drop-down list:

R - Anaconda

You’ll then see the following screen where you can type your code:

Jupyter

Step 4: 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(name = c('Jon', 'Bill', 'Maria'),
                 age = c(23, 41, 32)
                 )
print (df)

This is how the syntax would look in Jupyter Notebook:

How to Add R to Jupyter Notebook

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

Example of R code