Overview

Positron ships with first class support for R, along with Python. Start with our guide on how Positron discovers and manages R installations, then read on for details on working with R code in Positron.

Settings

Tip

If you’d prefer to customize Positron to feel similar to RStudio, learn what settings to consider.

Positron provides setting defaults for working with R, but you can override or change these defaults if you prefer a different experience. For example, Positron sets the tab size for R code to 2 spaces, but if you prefer 4 spaces, you can change the editor.tabSize setting for R files by adding the following to your user or workspace settings.json:

{
    "[r]":  {
      "editor.tabSize": 4
    }
}

You can see all the setting defaults that Positron provides with the command Preferences: Open Default Settings (JSON).

Keyboard shortcuts

The keyboard shortcuts in Positron are largely a superset of the keyboard shortcuts used by Visual Studio Code, plus additional keyboard shortcuts specific to Positron’s data science features. Some of those additional shortcuts are specific to R programming:

Shortcut Description

Insert the pipe operator (|> or %>%)1

Insert the assignment operator (<-)
, H Insert section

Load the current R package, if any, with devtools::load_all()

Build and install the current R package, if any

Test the current R package, if any

Check the current R package, if any

Document the current R package, if any
Tip

If you’d prefer to use keybindings as similar as possible to RStudio, learn how to enable them in Positron. This will overwrite some of Positron’s default keybindings, but will provide a more familiar experience for RStudio users.

You can create custom keyboard shortcuts as well.

Debugging

Positron currently provides initial debugging support via the Debug Adapter Protocol, including virtual document support for debugging package code. You can currently use:

  • browser() to set breakpoints in your R code,
  • traceback() to inspect the call stack after an error occurs,
  • debug(myFunction) to step through function calls, and
  • debugonce(myFunction) to step through a function call just once.

When you are in a debug session, you can use standard R debugging commands like n, s, c, and Q or the dedicated buttons on the debug toolbar.

Note

Positron does not yet support debugging R code via visual breakpoints in .R files. Follow along on GitHub for updates on breakpoints.

Footnotes

  1. You can choose which pipe operator to insert via the positron.r.pipe setting.↩︎