R Extension for Visual Studio Code

This VS Code extension provides support for the R programming language, including features such as R language service based on code analysis, interacting with R terminals, viewing data, plots, workspace variables, help pages, managing packages, and working with R Markdown documents. See the wiki for full documentation.
The R and R Markdown syntaxes are located in a sibling package vscode-R-syntax.
What's new in 3.0.0
v3.0.0 is a major release with faster, more reliable R session communication,
powered by the sess package. The extension includes sess
and prompts to install or update the bundled copy when needed. Missing Imports
are installed from the configured R repository. See the changelog
for other changes and upgrade notes.
Quickstart
Install R (>= 3.4.0) on your system. On Windows, we recommend letting the installer write the R path to the registry.
Install the languageserver package from R.
install.packages("languageserver")
Install the stable release of this extension from the VS Code Marketplace or the Open VSX Registry. This release requires VS Code 1.110 or later.
code --install-extension REditorSupport.r
To receive daily development updates, choose Switch to Pre-Release Version on the R extension's page in VS Code. New pre-releases are published to the VS Code Marketplace and Open VSX Registry when main changes and verification passes. Choose Switch to Release Version to return to stable releases. When reporting problems, include the extension version and reproduction steps.
Alternatively, you can test the latest development version by installing from GitHub:
Install the development version
The latest
pre-release is updated after successful verification of a push to main. Download and install it:
curl -fsSL -o vscode-R.vsix https://github.com/REditorSupport/vscode-R/releases/download/latest/vscode-R.vsix
code --install-extension vscode-R.vsix
Create an R file and start coding! (Click Yes if prompted to install sess.)
Steps 1–3 above are all that's required to get started with R in VS Code. But we also recommend the following software for a fully optimized R + VS Code experience:
Install an interactive plotting backend for a better R graphics experience:
- jgd: Lightweight JSON graphics device with native vscode-R integration.
- httpgd: SVG-based graphics device served via HTTP and WebSockets.
arf: A modern R console with many features: syntax highlighting, multiline editing, vi/emacs keybindings, R version switching, etc. Successor to radian written in Rust.
Complementary VS Code extensions:
- Quarto: the official Quarto plugin for VS Code.
- VSCode-R-Debugger: enables VS Code's debugging facilities for R scripts.
For example, assuming that you have installed arf and jgd, your user settings.json might include:
{
"r.consolePath": "arf",
"r.bracketedPaste": true, // recommended for arf (and radian)
"r.plot.backend": "jgd" // "auto" already prefers jgd, then httpgd
}
Please consult the relevant installation wiki pages for your OS (Windows | macOS | Linux) for more detailed instructions.
Set r.plot.backend to "native" to use R's configured graphics device without
opening the VS Code plot viewer automatically. The "standard" backend continues
to display static plots in VS Code.
Features
Snippets for R and R Markdown.
R Language Service: Code completion, function signature, symbol highlight, document outline, formatting, definition, diagnostics, references, and more.
Interacting with R terminals: Sending code to terminals, running multiple terminals, working with remote servers.
Package development: Build, test, install, load all and other commands from devtools.
Keyboard shortcuts: Built-in and customizable keyboard shortcuts.
Workspace viewer: Environment pane to show global variables in the attached R session.
Help pages viewer: Viewing R help pages and searching help topics.
Package management: Installing and removing R packages.
Session symbol hover and completion.
Data viewer: Viewing data frames, matrices, Arrow tables, and polars data frames in a paged, sortable, filterable grid; lists in a tree view.
Plot viewer: Interactive plot viewer with support for jgd and httpgd backends, plus a standard PNG/SVG fallback.
Webpage viewer: Viewing htmlwidgets such as interactive graphics and visual profiling results.
Browser viewer: Viewing interactive shiny apps.
R Markdown support: R Markdown chunk highlighting, chunk navigation, execute commands, and preview.
RStudio add-in support: Run supported RStudio add-ins in VS Code with a live R session.
Full support of Remote Development via SSH, Containers and WSL.
Exploring data
Call View(x) to open a table. The viewer loads rows on demand and applies column filters and sorting in R across the full table.
- Columns searches column names, shows or hides matching columns, and pins columns to either edge. Drag entries to reorder them. Row names stay pinned on the left.
- Filters shows filter inputs below the headers. Press Enter to apply text and number filters; use the filter button for ranges, missing values, or combined conditions. Clear filters removes every column filter, including filters on hidden columns. The toolbar shows the matching and total row counts.
- Columns fit the available width by default and adapt when the viewer is resized. Size to content sizes the currently displayed cells, up to 480 pixels, and keeps those widths; Fit width switches back to filling the viewer. Manually resized columns retain their widths while the remaining flexible columns share the space. Hover over a cell to see its full value.
- Repeated
View() calls for the same object retain the viewer's sizing mode, column layout, sorting, filters, and page size when the column names, order, and types are unchanged. Refreshed data starts on the first page. Reset view restores fit-width sizing, the default layout, filters, sorting, and configured page size.
Questions, bug reports, ideas, and contributions
Persistent R Interactive
This experimental feature provides native VS Code Interactive windows with independent arf sessions, including adoption of existing arf sessions over Remote SSH. vscode-R installs the bundled pure-R sess snapshot; missing Imports come from the configured R repository. Managed sessions retain streaming output, interruption, rich tables, HTML, and plots; notebook console input and debugger prompts are currently unavailable. See the setup and usage guide for session switching, persistence, rich outputs, and platform requirements.
| |