4  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.

4.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.

Tip

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 11, for saving and loading specific objects to your preferred location.

4.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:

install.packages(c("languageserver", "rlang"))

The httpgd graphics device is recommended.

Install it using:

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

4.3 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”.

There are different ways to install jupyter and jupyter-lab.

One way is:

  1. Install mambaforge

  2. Use mamba to install jupyterlab:

mamba install jupyterlab
  1. Install the IRkernel R packages:
install.packages("IRkernel")
# or install latest development version
remotes::install_github("IRkernel/IRkernel")
  1. Install the R jupyter kernel:
IRkernel::installspec()
  1. Start jupyter-lab:
jupyter-lab

There, you will be able to select the R kernel from the list of available kernels - usually at the top-right.