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
- Basic Usage
- Source code navigation
- Structure View
- Interactive Console
- Code completion
- Run Configurations
- Integrated Debugger
- Package Manager
- RMarkdown Support
- Platform features
- Site navigation
- Get Intellij IDEA, which is available as pro and as free open-source community edition from JetBrains.
- 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).
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. :-)
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
- Jump to declarations of symbols and locally defined functions with
Meta+Click. For example when being applied to a
read_excelcall, the IDE will navigate to the corresponding function declaration in the internally generated package index:
View -> Quick Definition Lookup (of functions): This will show the signature and a short title
- Search -> Highlight Usage: This will make Intellij to highlight all locations where a function or a symbol is being used
- Brace matching: If you position the caret before or after a bracket then IntelliJ will highlight the other element of the pair of brackets.
- Integration with R-Help: Simply invoke
F1on any symbol (data-sets, package names, functions).
- Documentation lookup for user-defined functions
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.
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
The following completion modes are available:
- Basic word completion for variables and local functions
- Completion of names for loaded packages
- Package name completion in library statements
- Coming soon: setwd() aware path completion
All refactorings can be accessed via the Refactor menu
- Renaming of symbols and functions
Inspections are on-the-fly checks of your R scripts, that highlight problems and (optionally) suggest automatic quick fixes
- Detect not yet installed packages in import statements
- Detect missing arguments in method calls
- Detect missing package imports
- Detect unresolved references (variables that are not defined)
- Detect forward references (i.e. variables that are used before declaration)
- Detect unused variables and function arguments
Intentions are quick-fixes provided and executed by the the plugin.
Auto-import of packages given a function name
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
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.
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.
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.
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!