[R] Line numbers with errors and warnings?

Duncan Murdoch murdoch.duncan at gmail.com
Sat Dec 1 00:34:43 CET 2012


On 12-11-30 4:22 PM, Worik R wrote:
> Is it possible to get a line number with an error report?

Yes, if the error occurs in code that has line number information.
You get line number info by default if you use source().  If the error 
is deeply buried in code that doesn't have the info (as it may be in 
your case), then the suggestions to use options(error=recover) will 
offer you a stack trace that shows you which high level code called the 
function reporting the problem.

Duncan Murdoch

>
> 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.
>
> cheers
> Worik
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list