Setting Up Your R Environment in VSCode

Step-by-Step Guide for Efficient R Development with VSCode

Discover how to fully set up your R programming environment in Visual Studio Code, including installing vscode-R, radian, languageserver, debugging tools, and plotting capabilities.

Tools
Author
Affiliation
Published

March 23, 2025

Modified

March 29, 2025

Keywords

setting up R in VSCode, R environment in VSCode, VSCode R setup, install vscode-R extension, R debugging in VSCode

Introduction

RStudio has traditionally been the preferred environment for R programming due to its extensive support for data analysis and interactive tasks. However, Visual Studio Code (VSCode) offers a more flexible, multi-language IDE that’s customizable through settings and a rich ecosystem of extensions.

By using the vscode-R extension, VSCode provides comprehensive support for R programming, combining core R features with flexibility to work on multi-language projects or remote servers.

This article guides you through setting up your VSCode environment for efficient R programming.



Essential Tools for R Programming in VSCode

The following tools and packages are essential for an optimized R environment in VSCode:

  • VSCode: Modern IDE supporting multiple languages.
  • vscode-R: Provides syntax highlighting, data viewer, workspace viewer, and integration with R Markdown.
  • languageserver: Offers intelligent coding features such as auto-completion, diagnostics, and documentation tooltips.
  • radian: Enhanced R console with syntax highlighting and advanced completion.
  • vscode-R-debugger: Adds powerful debugging capabilities, including breakpoints and step-by-step execution.
  • httpgd: Interactive graphics device for enhanced plot visualization directly within VSCode.
  • rmarkdown: Create reproducible reports and documentation.
  • Pandoc (optional): Enables documentation preview features within VSCode.

Step-by-Step Guide for Setting Up R in VSCode

Follow these clear steps to configure your R environment in VSCode effectively:

Step 1: Install R and VSCode

  • Install R: Download the latest version from the CRAN website and follow the installation guide.
  • Install VSCode: Download from the official VSCode website suitable for your operating system (Windows, macOS, Linux).

Step 2: Install vscode-R Extension

  • Open VSCode and go to the Extensions tab (Ctrl+Shift+X).
  • Search for REditorSupport.r and install the extension.
Note

Important OS-specific notes:

  • Linux/macOS: Default settings work with CRAN installations. For custom paths, update r.rterm.linux or r.rterm.mac.
  • Windows: Ensure the registry option is enabled during R installation. Otherwise, manually configure r.rterm.windows in VSCode settings.

Step 3: Install languageserver R Package

Install from your R console:

install.packages("languageserver")
Tip

Windows users should first install Rtools.

Step 4: Configure Radian for Interactive R Terminal

radian enhances your R terminal experience:

  • Install using Python’s pip:
pip install -U radian
  • Set radian as your default R terminal in VSCode settings (Ctrl+,):
"r.rterm.windows": "C:\\Python\\Scripts\\radian.exe",  
"r.rterm.mac": "/usr/local/bin/radian",
"r.rterm.linux": "/usr/bin/radian"

Adjust paths accordingly.

Step 5: Install Additional Tools

  • rmarkdown: Generate reproducible reports:
install.packages("rmarkdown")

Step 6: Set Up R Debugger in VSCode

Install debugging tools:

  • Install VSCode extension: R Debugger.
  • Install the corresponding R package:
install.packages("remotes")
remotes::install_github("ManuelHentschel/vscDebugger")

Step 7: Enhanced Plot Viewer with httpgd

To improve your plotting experience, install and configure httpgd:

install.packages("httpgd")

Activate it in VSCode settings (Ctrl+,):

"r.plot.useHttpgd": true

Conclusion

By following this guide, you’ve set up a robust and efficient R programming environment in VSCode. This setup combines the flexibility of VSCode with the powerful capabilities of R-specific tools, significantly enhancing your coding experience.

References & Further Reading

Back to top

Reuse

Citation

BibTeX citation:
@online{kassambara2025,
  author = {Kassambara, Alboukadel},
  title = {Setting {Up} {Your} {R} {Environment} in {VSCode}},
  date = {2025-03-23},
  url = {https://www.datanovia.com/learn/tools/r-in-vscode/setting-up-r-environment-in-vscode.html},
  langid = {en}
}
For attribution, please cite this work as:
Kassambara, Alboukadel. 2025. “Setting Up Your R Environment in VSCode.” March 23, 2025. https://www.datanovia.com/learn/tools/r-in-vscode/setting-up-r-environment-in-vscode.html.