Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What debugging tools does R lack that other languages have? [closed]

Tags:

r

debugging

I'm familiar with browser(), trace(), traceback(), and options(error=recover). I'm also playing with the debug package, which looks nice. All of these put R miles ahead of other statistical packages I've worked with in terms of debugging facilities. But in comparison to compiled traditional languages, the picture seems less favorable. Which gives rise to two questions:

  1. What debugging facility present in other languages do you miss the most?

  2. Is it possible to add this functionality in R as it exists current, or does it require a compiler, etc.?

Edit: Eliminated my proposed entry since as was pointed out it does exist in R.

like image 887
Ari B. Friedman Avatar asked Mar 01 '11 14:03

Ari B. Friedman


People also ask

What are the tools for debugging in R?

The built-in debugging tools (programs: functions) in R statistical computing environment are traceback(), debu(), browser(), trace(), and recover().

How do I debug code in R?

browser() function is inserted into functions to open R interactive debugger. It will stop the execution of function() and you can examine the function with the environment of itself. In debug mode, we can modify objects, look at the objects in the current environment, and also continue executing.

How do you debug a function?

To debug a function which is defined inside another function, single-step through to the end of its definition, and then call debug on its name. If you want to debug a function not starting at the very beginning, use trace(..., at = *) or setBreakpoint .

What does calling trace F for function f () do?

If an error occurs, the easiest thing to do is to immediately call the traceback() function. This function returns the function call stack just before the error occurred so that you can see what level of function calls the error occurred.


1 Answers

I'm afraid you're missing some options in R. You should take a look at the functions Rprof() and summaryRprof() for the -in depth- profiling of code. Next to that, check also the discussion on :

What is your favorite R debugging trick?

And especially the answer of Shane. That has some more interesting tips. There's also a whole chapter on debugging in the Writing R Extensions manual.

Lastly, keep in mind that quite some debugging tools for "compiled traditional languages" are implemented in the IDE, rather than in the language itself. As R can be coupled with Eclipse and Emacs to name a few, all those debugging tools are also available for R.

reworded

like image 90
Joris Meys Avatar answered Oct 23 '22 05:10

Joris Meys