Skip to content

Instantly share code, notes, and snippets.

@ryanbehdad
Last active April 27, 2022 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanbehdad/5fe57abdc664c8d09238744dbe730a21 to your computer and use it in GitHub Desktop.
Save ryanbehdad/5fe57abdc664c8d09238744dbe730a21 to your computer and use it in GitHub Desktop.
Coding in R using Visual Studio Code

Using Visual Studio Code for Programming in R

Extensions

The extensions to install:

R Language Server

For R LSP, you need to have R language server installed.

In VS Code open an R terminal and run:

  • install.packages("languageserver")

Aleternatively, you can run the above command in R Studio.

Linting

R LSP lintr needs to be disabled as its settings are difficult to configure. Instead, you can use R linting, which is configurable through VS Code settings.

To disable R LSP lintr:

  • Go the settings: R Lsp: Debug
  • Disable it

Change the settings of R linting:

  • Go to R > Linting
  • Change any settings, such as "Max line length" to 120.

Radian

Radian provides a more powerful terminal, in comparison to the default R interactive.

  • To install it, follow the instructions at https://github.com/randy3k/radian
  • VS Code settings:
  • Turn on r.bracketedPaste
  • Set r.rterm.windows to your Radian path
  • Examples:
    • C:/Users/ryan.behdad/AppData/Local/Continuum/anaconda3/envs/tf/Scripts/radian.exe
    • C:/Users/ryan.behdad/Miniconda3/envs/nostra/Scripts/radian.exe

Useful links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment