Introduction

This project provides an integration of R, which is a language for statistical computing and graphics, into Intellij IDEA.

The plugin provides syntax highlighting, import-aware code completion, a powerful and customizable code formatter, refactorings to reshape existing code, smart indentation, automatic detection and quickfixes for common coding issues, and sophisticated means to navigate your code and installed packages. Furthermore, it integrates tightly with R help and documentation, includes an interactive debugger, and allows to execute R code in an integrated console.

Table of Contents

Installation

  1. Get Intellij IDEA, which is available as pro and as free open-source community edition from JetBrains.
  2. To install the plugin, just open the plugin manager in Intellij Idea, search for “R Language Support”, and finally click install.

After you have restarted IDEA, the plugin will build an index of your local R package library, which allows for enhanced code completion, error highlighting, integrated documentation lookup and more. Depending on the number of packages in your R library the initial indexing procedure will require up to a few minutes to complete. The plugin will refresh this index on each IDE startup.

The plugin will try to infer the installation path of R automatically from your environment (e.g. PATH). On most platforms it will guess it correctly, but you can also set the path of the used R interpreter in the plugin preferences (Settings->Custom Languages->R).

Support

Feel welcome to ask questions, to report problems or to suggest new features by creating a ticket in our issue tracker. Before doing so, please check out FAQ.

Or be a hero and send us a pull request. :-)

Basic Usage

Just drag an R script into idea and start hacking.

Create a R script from the projects tools window:

You can also create a new project (the type does not matter) and organize your work into modules with differen content roots. Read the Intellij documentation for more details about how to do so.

By default the plugin is set to just work with files using the suffix .R. However, IntelliJ allows to associate file extensions to plugins (see Preferences->Editor->File Types).

Source code navigation

The following features are supported

Structure View

The plugin provides a Structure View which is accessible as a separate tool window or as a popup with Alt+F12. It allows to quickly jump to sections and functions definitions in the current script via narrow-down as you type search:

The sections are extracted based on the same model as used by knitr::spin. Headers are introduced by #' # Title , sections with #' ## Section and so on.

Interactive Console

Start a new console under Tools

To push code from the editor to the console use Ctrl+Meta+Enter. The IDE will either send the current code selection, or the most top-level expression at the caret.

You can also evaluate R code in an external console by means of the Send To Terminal plugin for Intellij. This allows to interactively use R on remote machines via ssh.

It is possible to run multiple consoles in parallel which will use separated R instances internally. This is handy to quickly switch between projects or when using scratch files

For a more general overview on how to use run consoles in IDEA see https://www.jetbrains.com/help/idea/2016.3/working-with-embedded-local-terminal.html

Code completion

The following completion modes are available:

Refactorings

All refactorings can be accessed via the Refactor menu

Inspections

Inspections are on-the-fly checks of your R scripts, that highlight problems and (optionally) suggest automatic quick fixes

Intentions

Intentions are quick-fixes provided and executed by the the plugin.

Run Configurations

To run or a debug a script with the IDE, simply right-click and choose Run, Debug to run immediately, or select Create… a run-configuration .

Once created, you can adjust the working directory, environment properties and other arguments passed on to R in the Run Configuration window.

Existing run configurations can be invoked from the toolbar

Integrated Debugger

To set or remove breakpoints simply click left from the editor:

See the previous section about how to create run configurations to run your scripts those in debug mode. When stopping at a breakpoint the IDE will show a listing of current environment variables including their types, as well as a console with current output.

You can then step through your code line by line, jump into or over function calls.

Package Manager

Packages can be installed from the “R Packages” tool window.

There you can also update existing packages if needed. Both CRAN and bioconductor are supported.

RMarkdown Support

Markdown support is avaialbe for Intellj IDEA as a separate plugin. Because of the ability to do language injection, R support is provided in Rmarkdown code chunks

Reports can be rendered using a dedicated tool, which can be configured as needed.

Alternatively you can also use run configurations to render Rmarkdown.

Platform features

The main strength of our plugin is the underlying Intellij IDE. So if you have not worked with it before, read more about all its amazing features. It ships with everything from SCM integration (Git, Subversion, etc.), neat SQL integration, bash scripting support, and so many more interesting features. However, its main “feature” is its usability. Give it a try!

Other R-IDEs