4 min read

My recommendations of VS Code extensions for R

As I have been constantly using R in VS Code for more than two years, the following is a list of my recommendations for VS Code extensions to improve the experience of R development and data research.

vscode-R

The R extension for VS Code. It provides the R language support and interacting with R terminals. The project wiki is a good place to get started and know more about the features.

vscode-R

R Debugger

The R Debugger for VS Code. It provides the capabilities to interactively debug R file, R package, or any R workspace. My previous post demonstrates this extension.

R-Debugger

C/C++

Many R packages implement their algorithms in C/C++ for performance and memory efficiency. If you need to write some high performance code in C/C++ to be used in R, the best choice is to use Rcpp or the much newer cpp11.

To work with a package that use both R and C/C++, it is best that you have the C/C++ extension installed so that you get the full capabilities of editing C/C++ code such as code completion, formatting, go to definition, rename symbol, find references, etc. You will have the ability to interactively debug Rcpp or cpp11 code through some configuration.

Rcpp

Error Lens

By default, the linting warnings and errors are only displayed by wavy underlines, which are not easy to spot until the code runs into errors. This extension displays the code diagnostics in a much more prominent way so that as you type the code in the editor, the linting runs, and the results are directly displayed along with the code of issues. It saves me a lot of time.

Error Lens

Path Intellisense

Path completion is a basic feature in RStudio but not a built-in functionality in VS Code. This extension provides just the path completion which is configurable.

GitLens

The built-in Git support in VS Code is amazing, yet this extension pushes the limit of Git integration to a whole new level.

GitLens

Git Graph

This extension makes it much easier to overview the Git history of the repo in a graph.

Git Graph

Live Preview

vscode-R supports live rendering of an R markdown document when it is changed. However, when the document becomes larger and the computing time longer, it is often not ideal to render on document change. This extension provides an alternative way to serve the rendered HTML file and automatically update when the file is changed.

Live Preview

vscode-pdf

Sometimes, I need to save the plots to a PDF file. It would be quite convinient if we can view the PDF file directly in VS Code. This extension provides such capability. It also supports automatic refreshing when the file is changed.

vscode-pdf

Remote Development

VS Code Remote Development makes it much easier to work with remote servers via SSH, Windows Subsystem for Linux (WSL), and Containers.

This extension makes it possible to unify the development experience on a remote or container environment just like a local one. If RStudio Server makes it much easier to work with R on a remote server, then VS Code Remote Development pushes the limit of user experience to a whole new level: No root privilege is required to install the server-side software. Instead, it automates the installation and it mostly works out of the box.

LiveShare

If you need live collaboration or teaching, this extension is exactly what you want. It shares your VS Code workspace with others so that you could edit the same file at the same time, or run code in the same terminal, view data, plots, help document, and even shiny apps together.

GitHub Copilot

I’ve been using GitHub Copilot for a couple of months. It is still in technical preview, and is not yet released to the general public, but it already works like magic, especially when the code I’m typing already exhibits some pattern. Although it is not perfect and makes mistakes, I strongly recommend that you sign up and try it if available.