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. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
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:> 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. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html
On Tue, 9 Nov 2004, Timur Elzhov wrote:> 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?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? -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
You might want to check out the "debug" package on CRAN: debug: MVB's debugger for R Debugger for R functions, with code display, graceful error recovery, line-numbered conditional breakpoints, access to exit code, flow control, and full keyboard input. Version: 1.0.1 Depends: R (>= 1.8), mvbutils, tcltk Date: 18/2/2004 Author: Mark V. Bravington Maintainer: Mark V. Bravington License: GPL version 2 or later> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Prof > Brian Ripley > Sent: Tuesday, November 09, 2004 4:16 AM > To: Timur Elzhov > Cc: r-help at stat.math.ethz.ch > Subject: Re: [R] R code debugging > > On Tue, 9 Nov 2004, Timur Elzhov wrote: > > > 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? > > 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? > > -- > Brian D. Ripley, ripley at stats.ox.ac.uk > Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UK Fax: +44 1865 272595 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >