A fresh start for R in VSCode

Setting up Visual Studio Code for R development 🤑

Varun Guttikonda
Analytics Vidhya
4 min readJul 30, 2020

--

Why am I writing this article?

As a data science major, most of my work with data-science (university or side-project) happens with R and Python. I write R in the traditional R console while all my other projects are done in VSCode. So I wanted to add R to my VSCode workspace.😉

When I searched the internet on how to do that, to my awe there was no article or YouTube video which tells how. I only found one article by Ken Run in which he describes his story and recommends his tools but not on how we could set up the environment.( Also many errors popped up while doing it his way )😓

So I searched the Internet and Stack Overflow about this and I wanted to write about it so anyone who is looking for instructions, can find it right away.🥳😎

Why VSCode?

  1. VSCode has support for most of the popular languages😍
  2. The community is huge and has plugins for every kind of language💖
  3. It has integrated terminal for faster development and takes less storage and has low memory footprint. It is identical to an IDE with the correct plugins plus I didn’t want to install R Studio🙂

What do you need?

  1. VSCode : A text editor my Microsoft
  2. R Language: The traditional R run time given by CRAN
  3. VSCode R Extension by Yuki Ueda
  4. R LSP Client for VSCode by REditorSupport
  5. Radian : A 21st century R console.

How to setup?

Firstly run the following command in your traditional R console:

Install the following extensions

  1. VSCode R Extension by Yuki Ueda

This extension integrates shortcuts and other key-bindings to run the code directly in the workspace or editor. You can view your environment and also see dataframes with a single click.

2. R LSP Client by REditorSupport

This extension provides linting, autocomplete and function signatures along with proper function definitions and information. This extension helps you autocomplete the function parameters by hinting the parameter names and types. It also gives intelligent suggestions on the scope of the variables in custom functions that you define.

3. Next run this command in the terminal to install radian. It is a python module which has better color scheme and representations for R outputs in console. It serves as an alternative to the R console.

4. Finally add these lines in the settings.json of your editor

That's it.🎉You have configured your VSCode to be a perfect IDE for R

Here is how my settings.json looks😅

Here are some screenshots for demo🙂

Function Signatures and Definitions
Running R code in the radian console
Plots and other stuff
Linting Capabilities
Information on hover

I’ll keep updating this post for more relevant and latest features that will be added👍

Thanks for Reading

--

--

Analytics Vidhya
Analytics Vidhya

Published in Analytics Vidhya

Analytics Vidhya is a community of Generative AI and Data Science professionals. We are building the next-gen data science ecosystem https://www.analyticsvidhya.com

Varun Guttikonda
Varun Guttikonda

Written by Varun Guttikonda

Computer Science || Data Science

Responses (13)