Debugging Parallel R Code

Parallel R packages such as Rmpi, snow, foreach, and so on do not set up a terminal window for each process, thus making it impossible to use R’s debugger on the workers. (My Rdsm package, which adds a threads capability to R, is an exception to this.)

What then can you do to debug apps for those packages? Let’s consider snow for a concrete example.

First, you should debug the underlying single-worker function, such as mtl() in Section 16.2. Here, we would set up some artificial values of the arguments and then use R’s ordinary debugging facilities.

Debugging the underlying function may be sufficient. However, the bug may be in the arguments themselves or in the way we set them up. Then things get more difficult.

It’s ...

Get The Art of R Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.