install.packages(c("languageserver", "rlang"))
5 IDEs
An Integrated Development Environment (IDE) is a software application that offers extensive functionality for programmers, including ability to read, write, and execute code, develop and test software packages, etc.
IDEs that support R usually also allow viewing plots or launching web applications within the same environment. An IDE can make working in R easier, more productive, and, importantly, more fun.
5.1 RStudio by Posit
Posit (formerly RStudio), develops RStudio Desktop, a popular integrated development environment (IDE) for R, which can be downloaded from here. This is the recommended environment for beginners. Make sure to keep your installation up-to-date.
It is recommended to set up a new RStudio project for each data project.
RStudio projects allows you to organize your work. Each project keeps track of your working directory, workspace, history, and source documents.
To create a new RStudio Project click on File > New Project… from the main menu or the “Create a project” icon (second from top-left usually) in the RStudio toolbar.
RStudio may ask you whether to save your workspace upon exit. That’s the same question that R will ask when you terminate a (default) R session in the console.It is recommended to answer “No”. If you answer “Yes”, it will save all objects currently in your workspace to a file called .RData
in your working directory. Next time you start RStudio, it will reload all objects from this file. This can make RStudio slow to start and will clutter your workspace with objects from previous sessions, which you are unlikely to need or remember what they are/how they were created. Instead, see Chapter 12, for saving and loading specific objects to your preferred location.
5.2 VS Code
Visual Studio Code, a.k.a. VS Code, is a source code editor and one of the most popular IDEs across different languages. The VS Code Extension Marketplace includes a very large number of extensions.
The ‘vscode-R’ extension allows using VS Code as an R IDE. To use it, you need to install the languageserver
and rlang
packages:
The httpgd
graphics device is recommended.
Install it using:
install.packages("httpgd")
and enable it in the extension settings (“Plot: Use httpgd”).
The ‘Remote - SSH’ extension allows using a local VS Code installation (e.g. on your laptop) and executing code (R, Python, etc.) on a remote server on which you have SSH access.
VS Code’s ‘Jupyter’ extension allows you to open and run jupyter notebooks.
Read more about R support in VS Code here
5.3 Positron by Posit
Positron is “a next-generation data science IDE” built by Posit. First public release was made available on June 24 2024 and as stated in the GitHub repo “is an early stage project under active development”. This is a new IDE by the developers of RStudio built on top of VS Code open source (“Code OSS”). May be too new and untested for beginners, who might benefit from sticking with RStudio for the time being. May be fun to try for more experienced users and those already familiar with VS Code.
5.4 Jupyter / Jupyter Lab
Jupyter is a popular notebook interface, which supports multiple programming languages, including R.
JupyterLab is the “next-generation web-based user interface for Project Jupyter”.
Jupyter and JupyterLab are installed using Python, but can be used to work with multiple languages, including R.
Python environments are a way to isolate your project’s dependencies from the rest of your system. This is useful when you have multiple projects with different dependencies, or when you want to avoid conflicts between packages. There are different approaches to installing Python packages & managing environments. Our current recommendation is to use virtual environments and handle dependencies using uv
, which is a much faster alternative to the classic pip
. The alternative is to use conda
or
5.4.1 Using uv
& pip
(recommended)
Create a new virtual environment named, for example, myenv
:
python3 -m venv myenv
Activate your new virtual environment:
source myenv/bin/activate
Install uv
, a faster alternative to pip
:
pip install uv
Install jupyterlab:
uv pip install jupyterlab
5.4.2 Using conda
We recommend starting by installing miniconda
(system shell) First, use conda to install jupyterlab
on the command line:
conda install -c conda-forge jupyterlab
- Then, install the
IRkernel
R package withn R:
install.packages("IRkernel")
# or install latest development version
remotes::install_github("IRkernel/IRkernel")
- Install the R jupyter kernel:
IRkernel::installspec()
(system shell) Start jupyter-lab:
jupyter-lab
There, you will be able to select the R kernel from the list of available kernels.