Skip to content

R code debugging

4 messages · Ernesto Jardim, Timur Elzhov, Sean Davis +1 more

#
Hi,

Check R's manual "R Language Definition".

Regards

EJ
On Tue, 2004-11-09 at 11:52, Timur Elzhov wrote:
#
Dear useRs,

it's quite difficult for me to find `Error:'s in my R code, because R does
say about error itself, but say nothing about its location, say, string
number and file with an error (which may be `source'd from another file).
Are there any option for turning of the similar feature, or R can not do
such a thing at all?

Thanks.


--
WBR,
Timur.
#
You are probably interested in traceback().  See ?traceback.  Also, the 
debugger is your friend.  See ?debug.

Sean
On Nov 9, 2004, at 6:52 AM, Timur Elzhov wrote:

            
#
On Tue, 9 Nov 2004, Timur Elzhov wrote:

            
R code can be created dynamically by R code (called `computing on the
language'), and in most cases the source code is not retained (and it is
not used for execution).

traceback() will always tell you the function in which the error occurred.
If you write reasonably modular code that should suffice, but if not,
use debug() on that function and single-step through it to find where the 
error occurs.  Or set a suitable error handler: have you explored 
recover(), for example?