Skip to content
Prev 12332 / 63461 Next

More user-friendly error message needed.

(Moved from r-help to r-devel).

On 07 Apr 2004 15:07:49 -0400, Shin <sdhyok@email.unc.edu> wrote :
There are several places this could be fixed.  When you use x$z, the
code for $ could give an error message or a warning; instead it
returns NULL with no error or warning.  Changing this would probably
be dangerous:  I'd guess there's code out there that relies on getting
a NULL back from a construction like that.  But maybe we should change
that in 2.0?

Then plot(NULL) is called, which eventually results in the message you
saw.  That could be easily fixed:  plot.default could have 

if (is.null(x)) stop("x is NULL")

I can't think of a reason why this would cause trouble.  However, if
you had something like

plot(x$y, x$z)

the error wouldn't be detected.

Finally, the actual error message comes from a bug in the xy.coords
code: it has 

           y <- x
            x <- 1:length(x)

for the case where there is a NULL y supplied, and this is wrong:  it
should be x <- seq(along=x).  Making just this fix gives a fairly
inscrutable error message:

Error in plot.window(xlim, ylim, log, asp, ...) : 
        need finite xlim values
In addition: Warning messages: 
1: no finite arguments to min; returning Inf 
2: no finite arguments to max; returning -Inf 
3: no finite arguments to min; returning Inf 
4: no finite arguments to max; returning -Inf 

but this might be easier to figure out than the original one.

Duncan Murdoch