The second part of the Cursor for R series. Learn how to set up Jupyter Notebooks for R inside Cursor.
This is Part 2 of my mini-series on making R work smoothly inside Cursor since I could not find a single tutorial online. In Part 1, I showed you how to install Cursor and set up R. Now, we'll take it further and run R in Jupyter Notebooks - fully inside Cursor.
To run Jupyter Notebooks (for R or any other language), you first need to install the jupyter command line tool (More info and alternative installation options). Open your terminal and run:
pip3 install jupyter
# or pip install jupyter
You can test if it installed correctly by running jupyter notebook in your terminal. This should give you a link to paste into your browser. If that works: great! You're ready to go.
Now we connect R to Jupyter using the IRkernel.
A kernel is what runs your code inside a notebook. Jupyter supports different kernels for different languages. For R, we use IRkernel. (Later I also show how to set up a bash kernel).
Inside R (either by typing R in your terminal or in your installed Cursor .R file), run:
install.packages("IRkernel")
IRkernel::installspec()
For more information about IRkernel, check out the IRkernel documentation.
Once IRkernel is installed, you can create a new .ipynb file in Cursor.
When you open it, Cursor should prompt you to install the Jupyter Notebook extension (if it hasn't already).
To switch to the R kernel: Click Select Kernel (top right) → Jupyter Kernel → Choose R.
If you don't see the R kernel right away, restart Cursor and try searching for R in the kernel selection menu.
You can also check your installed kernels with:
jupyter kernelspec list
If ir appears (see Terminal section of image below), your R kernel is ready!
Sometimes it's useful to run shell commands directly in a Jupyter Notebook (e.g. for preprocessing or documenting data). You can install a Bash kernel like this:
pip install bash_kernel
python -m bash_kernel.install
After installing, click Select Kernel (or where the current kernel is selected as in the image below), and you should see "Bash" as an option (or you can search for it in the Jupyter Kernel...-section) as shown below:
Here's a checklist if something isn't working:
jupyter command not found → Install with pip3 install jupyter (see Jupyter installation documentation for more options)update.packages() and install dependencies one-by-one. If asked to compile from source and you're unsure, answer "No" - the older version usually works fine.jupyter kernelspec listR.version.string and compare with what Jupyter uses.libPaths() → You can align R paths in Cursor and RStudio if neededFor additional help with Jupyter Notebooks, refer to the official Jupyter Notebook documentation.