R Radian Terminal in VS Code

Author

Matthew DeHaven

Published

April 22, 2024

This is a guide for installing and setting up the R Radian terminal to use with Visual Studio Code.

If you do not already have VS Code installed, install it here.

You also need to already have R and Python installed.

What is Radian?

Radian is a Python package that runs in the background and pretends to be a nice R terminal. In fact, it is just takes your R commands, runs them in an actual R process, then returns you the results. But this extra complexity allows for a nicer R terminal with…

  • colors
  • multiline syntax
  • automatic width adjustment
  • auto complete
  • and more!

Example screenshot from radian Github page.

Installing Radian

  • Run the following in a terminal:
terminal
pip3 install -U radian
Caution

You may get “error: externally-managed environment” + a lot more text. This is most likely because you installed Python using Homebrew. It is trying to force you to use a Python environment, but in this case you don’t want to. Use the following command to override it: pip3 install -U radian --break-system-packages (it sounds scary but it’s okay).

You can now launch a Radian terminal by simply running radian in a terminal.

Setup Radian in VS Code

Now we want to tell VS Code to use Radian by default.

  • Set the following values in VS Code Settings:
{
"r.bracketedPaste": true,
"r.rterm.mac": "/opt/homebrew/bin/radian"
}

You can either search for each setting in VSCode’s Setting GUI, or open “settings.json” and paste in these values.

The settings above are for MacOS with Python installed with Homebrew. Your radian package may be installed in a deferent location. Run which radian in a terminal to find the correct path for your machine.

If you are using Windows set "r.term.windows" setting, and for Linux, the "r.rterm.linux" setting. Also on Windows, use which.exe radian to find the correct path.

Turning on “Bracketed Paste” allows you to paste multiple lines of code into the terminal at once.

You should now be able to launch a new R terminal in VS Code and see your new terminal!