[R] Line numbers with errors and warnings?

David Winsemius dwinsemius at comcast.net
Fri Nov 30 22:44:52 CET 2012


On Nov 30, 2012, at 1:22 PM, Worik R wrote:

> Is it possible to get a line number with an error report?
> 
> I have a long script and an error:
> 
> Error in `[.xts`(x, xsubset) : subscript out of bounds
> 
> 
> It would be very helpful, and save a lot of time, if there was some
> indication in the error message which line the error was.
> 
> I can find it using binary search but that is a painful process.

Generally if one is in an interactive mode, one is advised to use the error recovery process provided by:

 options(error=recover)

You should then be dropped into the browser in the environment of the error. Execute ls() to see what variables are accessible in the local environment. So you also need to consult:

?browser


-- 

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list