Running R in VS code
Visual Studio code is a free and open-source code editor developed by Microsoft. It is available for Windows, macOS, and Linux. It has become one of the most popular code editors among web developers, in my case I'm spending most of the time between this IDE, and the Copilot CLI.
VS code has extensions for many languages, and I've been using it for Angular, C#, SQL Server for years. and most recently I'm using
Installing R
Installing R in a Windows machine
The cleanest way to install R in a Windows machine is to do it throug the Windows Package Manager (winget). You can also install R through the official R project website.
winget install RProject.R --version 4.5.2
Installing the R language server
The R language server is the component that gives Visual Studio Code “RStudio‑like intelligence”: autocomplete, function hints, code navigation, etc.
install.packages("languageserver")
installed.packages()[, c("Package", "Version")]
Install the R VS Code extension
If you search for R extensions in Visual Studio Code you'll find a few options, we will go with the one recommended in the Visual Studio Code website.
- Name: R
- Publisher: REditorSupport
Run a simple file
Test with a simple file to verify we have everything setup correctly.
x <- 1:10
plot(x)
At this point you should have everything set and running!