Logo with initials

How to install and use R in VSCode, for beginners

Most of the R world uses RStudio, which I cannot stand. It’s ugly, slow and cumbersome.

RStudio also manages the language R itself, which makes troubleshooting very hard. The default answer is often “Have you tried reinstalling R?”

This is not 2003 anymore. I prefer:

  1. Reproducible installation steps
  2. A modern coding editor (VSCode)

Here’s how to do that.

1. Install R itself

brew install r

That will install Python3 too, because why not.

2. Install dependencies

Optional: Install radian, which is pretty R console.

pip3 install -U radian

Install the language server

Open a terminal

Type r to get into the R console.

Install the language server by typing this: install.packages("languageserver")

It’s going to take forever because it’s compiling C++ libraries like it’s 1993 …

Get out of this ugly console: q()

3. Make it work with VSCode

Open VSCode.

Install the R Extension for VSCode

Add the following properties to your settings.json

"r.bracketedPaste": true,
"r.rterm.mac": "/usr/local/bin/radian"

Enjoy!

Create an R file, then write some R code in it.

print("Hello World!")

Click on the “Run source” icon on the top right. It looks like a play button.

Watch it run on the terminal, you’re done!