Back to articles
Visual debugging with RIDE
by in

On R-Blogger there was an interesting article that compares debugging support for R in RStudio and Eclipse StatET [1]. I liked that article very much, but it misses the new RIDE environment, which I am going to add to the comparison in this article. RIDE is a Jupyter-based development environment for R and Python,which provides integration of visual debugging features, such as using breakpoints in code editor, stepping through code, and inspecting variables.

It is provided as a cloud service by R-Brain.

Breakpoints

Setting breakpoints in RIDE is as easy as clicking on the left hand side of an editor. There is instant feedback on the status of a breakpoint. If a breakpoint cannot be set, you will see a grey circle, e.g. in case the opened R file has not yet been sourced. Check the convenient option 'Automatically Source File on Save' in editor's toolbar.

set-breakpoint-in-my-code.gif

All breakpoints are shown in the BREAKPOINTS section in the environment view. If you switch to another kernel session, e.g. by starting a new console, all managed breakpoints are set automatically.  

In contrast to RStudio you can even set breakpoints in the code of installed packages. Just open an editor of  a function, e.g. by double-clicking in the VARIABLES section. Set a breakpoint on a line where next execution of this function should be paused as if it was your code.

Debugger

When a breakpoint is reached and execution of code is paused, the Environment view is revealed automatically and you will see the call stack.

CALL STACK Section

Clicking on any entry in the CALL STACK section will reveal and highlight the corresponding location in the code editor. The topmost frame gets revealed automatically on each step during debugging.

switching-between-frames.gif

In the header you will find the typical actions to control the debugger, such as ‘Continue’, ‘Stop’, ‘Step Over’, ‘Step In’, and ‘Step Out’.

call-stack-section.png

VARIABLES Section

The VARIABLES section is used to inspect the values and functions of the global and all package environments. During a paused debugging session it also shows the environments of the currently selected frame from the call stack.

inspect-scope-of-frames.gif

One general advantage of RIDE’s variable browser is, that it allows drill-down into contents of variables, which I find very useful when working with dataframes, local environments or R6 classes.

structured-variables.png

Conclusion

RStudio and StatET are mature IDEs for R, yet RIDE is a breath of fresh air. In terms of dealing with package code, RIDE makes it easier to set breakpoints and provides more precise location, which makes debugging even easier. Being able to set breakpoints in package code and inspect the structure of data in the environment view are useful additions to the feature set provided by RStudio.

Today, RIDE comes with debugging support for R by extending the Jupyter Kernel protocol. The next goal is to implement those Environment and Debug protocol extensions also for Python.

[1] https://www.r-bloggers.com/visual-debugging-with-statet-and-rstudio/

 
Back to articles
Try R-Brain for Free

R-Brain is a powerful data science platform, where you can build sophisticated models, collaborate with others, learn and experiment. Try for free, no credit card required.
Try for Free