Introducing Positron: A New, Yet Familiar IDE For R And Python

This article was first published on Appsilon | Enterprise R Shiny Dashboards , and kindly contributed to python-bloggers. (You can report issue about the content on this page here)
Want to share your content on python-bloggers? click here.

Nowadays, most data professionals choose either R or Python when it comes to a programming language of choice. But what if you need both? Do you have to constantly switch between environments and IDEs? That’s one option, sure, but leaves a lot to be desired.

To solve this problem, Posit came up with Positron IDE – a development environment for data scientists, supporting R and Python out of the box. The IDE is currently in public beta, meaning anyone can install it.

Today you’ll learn what this new IDE is all about and how it compares to existing solutions.

Want to work with Appsilon? Here’s our exact process for delivering impactful products.

Table of contents:

  • Hello Positron IDE – Key Features You Must Know
  • Running Code in Positron IDE – Tips and Tricks
  • Frequently Asked Questions about Positron IDE
  • Current Limitations and Future Potential
  • Summing up Positron IDE

Hello Positron IDE – Key Features You Must Know

Positron is a next-generation data science IDE delivered by Posit. It’s still in active development, so it’s expected to see some features not working properly (more on this later). But, as mentioned in the introduction, it’s in public beta, which means you’re free to take it for a spin!

You can download the latest Positron release from the official GitHub releases page.

In essence, Positron is a fork of a famous IDE – Visual Studio Code. If you’re familiar with it, Positron should feel right at home. It has some neat features delivered out of the box, but you could configure most of these through plugins on a fresh VSCode installation.

Up next, let’s discuss some key features you must know about.

RStudio Meets Visual Studio Code

Here’s what you’ll see when you first launch Positron:

Image 1 – Positron IDE welcome screen

It certainly looks like a combination of RStudio and Visual Studio Code! You’ve got your familiar sidebar for navigation and extensions, but also your four-panel view for code, console, plots, and variables.

The top left panel allows you to start working on your data science projects – either in R or Python, through a notebook or file. Positron automatically detects installed programming languages and their version, but also picks up any virtual environments you’ve previously created:

Image 2 – File/project creation in Positron IDE

Up next, let’s explore this multi-language and multi-format support in more detail.

Multi-Language Support

The big selling point of Positron IDE is that it comes configured for R and Python out of the box – Jupyter Notebooks included. This means you don’t have to set everything up from scratch, which in the case of R and Jupyter is not as easy as it sounds.

To create a new R script, click on the New File button on the welcome screen and select R File. Writing and running code works just like in RStudio – Command/Control + Enter will run the cell on which your cursor is located:

Image 3 – Working with R files in Positron

The same approach to writing and running code works in Python scripts – write any code block you want and hit Command/Control + Enter to run it:

Image 4 – Working with Python files in Positron

Still, we think Jupyter notebooks allow maximum flexibility. You can create a notebook with a default programming language profile (R or Python), but you can then change the language for each cell.

Because of this flexibility, you can also sprinkle text/markdown content between your cells to provide resources or explanations:

Image 5 – Working with Jupyter Notebooks in Positron

And that’s the basics of programming language and format support in Positron. Up next, let’s discuss some more advanced features.

Ark Kernel

Ark is an R kernel for Jupyter applications and is a default interface between R and the Positron IDE. Previously, you’d have to install IRkernel if you wanted to run R in Jupyter Notebooks. You also had the option to install Ark, but it now ships by default with Positron.

What Ark does for you is provide structured interaction between R language and Jupyter, enable IntelliSense features through the LSP server, and sophisticated step-debugging of R functions through a DAP server. Now, Ark doesn’t support breakpoints so far, but you can use `debug()`, `debugonce()`, or `browser()` as substitutes.

Let’s talk more about the IntelliSense part. For example, you can hit Tab to display autocomplete suggestions:

Image 6 – Autocomplete suggestions

This also works if you want to, for example, list all functions available in a given package:

Image 7 – Autocomplete suggestions (2)

Sure, it’s nothing groundbreaking, and is something you’ll take for granted if coming from RStudio, but Jupyter and R don’t always work nicely. Ark kernel is a way to fix that, and thanks to Positron, you don’t have to install and configure it manually.

But by far the most important quality of life improvement for developers is box imports. Let’s talk about them next.

Box Imports

Box imports are somewhat of a mess in VSCode and RStudio. In VSCode, you can’t Control/Command + Click to get to the source function definition, and in RStudio, it only works when calling the function (not when importing it). Positron has thankfully solved this problem.

Here’s an example – we have a `my_square_function()` exported in `r_code/functions.R`:

Image 8 – Box imports example

As you can see, you can now get to the function definition both from the import and from the function calls!

And that’s the basics of Positron for you! Up next, we’ll go over some tips and tricks for running code in this new IDE.

Running Code In Positron IDE – Tips And Tricks

Positron, being a mixture of RStudio and Visual Studio Code, combines the best features of both worlds. This section will take you through useful keyboard shortcuts and features for working with data.

Useful Shortcuts

While you don’t necessarily need to use keyboard shortcuts, they significantly improve developer productivity. The following image illustrates what it takes to run a single cell without keyboard shortcuts:

Image 9 – Running Jupyter cell without shortcuts

Manually clicking on the play button will become pretty annoying after a couple of iterations. Instead, you can opt for one of the following:

  • Control + Enter: Run the current cell without creating a new one
  • Shift + Enter: Run the current cell and create a new cell for the same programming language

While in a notebook environment, you might also find the following shortcuts useful:

  • C: Copy cell
  • X: Cut cell
  • V: Paste cell
  • D: Delete cell
  • Command/Control + P: Navigate between files

Note that they are different from the usual jupyter notebook keyboard shortcuts, but you can see the full list of available shortcuts in Settings – Keyboard Shortcuts. Every shortcut is adjustable.

DataFrame Viewer

Dataframes are the core of all data science workflows, so having an IDE that can display all relevant information about them is a must-have feature.

Positron allows you to print the dataframe content to the R console by calling R-specific functions, such as `head()`:

Image 10 – Printing the top 6 rows of a dataframe

But the more interesting feature is the dataframe viewer. Once your dataframe is declared, you’ll see it in the Variables panel. You can expand the variable to view all columns and their respective values, or you can click on the table column to inspect the dataframe in an Excel-like fashion:

Image 11 – Dataframe inspection

As you can see, you can sort the values, apply filters, inspect missing values, and much more – straight from the GUI.

Plot Viewer

An amazing feature of RStudio is the plot viewer. You have a dedicated panel for visualizations, and you can easily cycle through multiple charts. Positron has the same feature, arguably with a somewhat updated interface:

Image 12 – Plot inspection

Creating a new chart won’t delete the old one, as you can easily navigate between them using the right-side panel:

Image 13 – Plot inspection (2)

Up next, let’s discuss the powerful and improved variable inspector.

Variable Inspector

Being able to inspect complex objects, such as plots, is an essential feature for debugging code and making sure everything works as expected. RStudio also has this feature, but Positron allows you to dig deeper and has a sleeker-looking user interface:

Image 14 – Variable inspection

As you can see, you can drill down into all the small pieces that are combined to make complex objects.

Frequently Asked Questions About Positron IDE

Positron IDE is currently in open beta, so this section will answer the most commonly asked questions posted by the community.

Positron is a fork of VSCode, so why not just use VSCode?

R support in VSCode exists, but it tends to break every couple of patches due to interactions with other extensions. Positron solves this problem by supporting R out of the box and having a brand new Jupyter kernel, Ark, with blazing-fast IntelliSense. Additionally, plain VSCode doesn’t have a dedicated R console.

Is Positron a replacement for RStudio?

No, Posit is going to support both Positron and RStudio moving forward.

GitHub Copilot and Remote SSH plugins aren’t working – What can I do?

Positron IDE is currently in open beta, so you can expect occasional hiccups. Since it’s a VSCode fork, you’d expect that every VSCode plugin would work. That’s currently not the case for GitHub Copilot due to Microsoft licensing, A couple of other must-have plugins, such as Remote SSH and DevContainers also don’t work. The remote SSH plugin is in Posit’s roadmap for Positron, so they should have it sorted out soon.

Are all RStudio features supported in Positron?

Most RStudio features are available in Positron, but the support is currently lacking for inline Quarto output, R Markdown profiling, Sweave, RStudio Add-in support, and even for easy publishing Shiny/Quarto apps/reports to Posit Connect or Shinyapps.io.

Current Limitations And Future Potential

With everything said today, let’s now make a quick TL;DR of everything you might find annoying about Positron IDE public beta release coming from RStudio or Visual Studio Code:

  • Feature support – Unlike RStudio, Positron doesn’t support inline Quarto output, R Markdown profiling, Sweave, RStudio Add-in support, and support for easy app and report publishing.
  • Plugin support – Positron is a fork of VSCode, but major VSCode plugins such as Copilot, Remote SSH, and DevContainers are not working.
  • No wow factor – Being based on VSCode, Positron doesn’t feel like anything new, so many users that already have a properly configured environment don’t have the urge to switch (or even give it a try).

Still, Positron is currently in public beta, so it’s not 100% fair to compare it to a product that’s been in a stable release for years. Many things can, and hopefully will, change before it’s out for good.

Summing Up Positron IDE

To summarize, Positron is a new IDE from Posit, the authors of RStudio. It’s not designed to be a replacement for RStudio, as both will be maintained moving forward. It’s a new product, aiming to be a one-stop-shop for data science workflows (R and Python). In the current public beta release, it’s still a bit rough around the edges, as the plugins we rely on daily simply don’t work.

If you’d like to learn more about Positron, make sure to visit the official GitHub repository. If you want to take it out for a spin, download the latest version from their release page. We encourage you to do so, and also to share your feedback with us (comment section below), and with Posit.

Have you already tried the Positron IDE? Do you think it’s a viable RStudio/VSCode replacement for data science workflows? We’re eager to hear your opinion in our Slack community.

Looking to containerize your R Shiny application? This article reveals if you should go with Docker, Podman, or Singularity.

The post appeared first on appsilon.com/blog/.

To leave a comment for the author, please follow the link and comment on their blog: Appsilon | Enterprise R Shiny Dashboards .

Want to share your content on python-bloggers? click here.