Run and debug R scripts
Run an R script
Click on the R file toolbar.
Analyze results in the R console and Data View tool windows.
The R console launches and displays the execution results sent to the standard output. PyCharm also opens the R Graphics window if the script renders any visual content.
The Variables tab of the R console helps you analyze the values of the variables during script execution. The icon on the left of each variable indicates its type:
Click a View link to preview the array value in the popup and a View Table link to preview data in the Table View tool window.
If needed, save the results. In the R Graphics window, click to save the plotted content in a .png file. In the Table View window, click to save the table in a .csv file.
Debug an R script
You can debug your R script to detect any errors in the code.
Click on the R file toolbar.
The debugging process stops at a breakpoint and you can preview the current results in the Variables window.
Control the script execution with the debugging toolbar:
Tooltip and Shortcut
When the current application is stopped at a breakpoint, click this button to resume execution. When an application is running, this button toggles to .
Click this button to pause program execution.
Click this button to terminate the current process.
Click this button to execute the program until the next line in the current method or file, skipping the methods referenced at the current execution point (if any). If the current line is the last one in the method, execution steps to the line executed right after this method.
Click this button to have the debugger step into the method called at the current execution point.
Click this button to have the debugger step out of the current method, to the line executed right after it.
Run to cursor
Click this button to resume program execution and pause until the execution point reaches the line at the current cursor location in the editor. No breakpoint is required. Actually, there is a temporary breakpoint set for the current line at the caret, which is removed once program execution is paused. Thus, if the caret is positioned at the line which has already been executed, the program will be just resumed for further execution, because there is no way to roll back to previous breakpoints. This action is especially useful when you have stepped deep into the methods sequence and need to step out of several methods at once.
If there are breakpoints set for the lines that should be executed before bringing you to the specified line, the debugger will pause at the first encountered breakpoint.
Use this action when you need a kind of a temporary breakpoint at a specific line, where program execution should not be interrupted.
Click this button to open the Breakpoints dialog where you can configure R breakpoints behavior.
Use this button to toggle breakpoints status.
When the button is pressed in the toolbar of the Debug tool window, all the breakpoints in a project are muted, and their icons become grey: .
You can temporarily mute all the breakpoints in a project to execute the program without stopping at breakpoints.
Click this button to open the Evaluate Expression dialog.
To execute or debug a code fragment, select the fragment and press or . When running code fragments, mind code dependencies. All variables used in the executed fragments must be initialized.