[R] Explanation of Error Diagnostics

Thomas Lumley tlumley at u.washington.edu
Mon Apr 29 17:17:53 CEST 2002


On Sat, 27 Apr 2002, graham lawrence wrote:

> Hi,
>
> Is there any documentation to explain R's error diagnostics, e.g. messages
> like
>
> >source("../src/sources/routine.R")
> Read 8 records
> Read 2 records
> Error in "[<-"(*tmp*, !test, value = rep(no, length = length(ans))[!test]) :
>         incompatible types
>
> The nature of the problem incompatible types, is clear; but I'm more
> interested in its location, and feel that the cryptic elements
> "[<-"(*tmp*, !test, value = rep(no, length = length(ans))[!test])
> probably hold the key to finding it.
>

The first step is the traceback() function, which lists the function that
"[<-" was called from, the function that was called from, and so on up to
the source() function. It may then be obvious where to look.

Assignment functions are initially even more obscure than other functions
because what you see is not the actual call.  The actual call would have
been
  somevector[!test]<- rep(no, length = length(ans))[!test]
and while you can't work out the name of the vector, the rest may look
familiar.

Finally, in R1.5.0 look at the recover() function
  options(error=recover)
launches the browser when an error occurs, and options(error=NULL) turns
this off. In older versions of R, or for saving debugging information for
later examination look at dump.frames() and debugger().


	-thomas

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list