Edit R files
When you have created and configured an R project in PyCharm, you can start editing the default main.R file. However, you can add more .R and .rmd files to your project.
Add new R and R Markdown files to the project
Do one of the following:
Right-click the target directory in the Project tool window, and select New from the context menu.
Select R Script or RMarkdown file.
In the dialog that opens, type a filename.
A new file has the .R or .rmd extension and it is marked with the corresponding icon: .
PyCharm enables code assistance to facilitate editing and validating R code:
Code completion helps you complete the names of classes, functions, and variables. Start typing the name of the code construct, and the suggestion list appears.
Code inspections detect and correct various problems in your R script.
As soon as the IDE finds a way to improve your code, it displays a yellow bulb icon in the editor next to the current line. By clicking this icon, you can view intention actions available in the current context. Intention actions cover a wide range of situations from warnings to optimization suggestions.
Quick fixes allow you to resolve a detected problem in one click. A red bulb with an exclamation mark indicates the problematic code and prompts you to select an associated fix. Click the bulb icon or press Alt+Enter to open the list of the fixes.
With the quick fixes for missing import statements you don't need to manually add every single R package to your project. You can just select the Install all missing packages in file option and PyCharm automatically installs all the packages required for your R script.
PyCharm automatically saves changes that you make in your files. Saving is triggered by various events, such as compiling, running, debugging, performing version control operations, closing a file or a project, or quitting the IDE. Most of the actual events are predefined and cannot be configured, but you can be sure that changes will not be lost as you work.
With the R plugin you can quickly preview reference documentation for a particular variable, class, type, or argument. In the R console, type
?and the code element name, for example,
?barplot. The corresponding reference documentation appears in the Documentation tool window.
When editing an R file, you can quickly navigate through your code and jump to a particular variable or function. You can open the Structure tool window or select the target variable in the editor and click the corresponding breadcrumb element to open the structure popup window.