[R] More user-friendly error message needed.

Shin sdhyok at email.unc.edu
Wed Apr 7 22:09:47 CEST 2004

Thanks for your kind explanation.
Actually, I just begin to learn R, so not familiar with many behaviors
of R yet. As a user of Python and MATLAB, I understand the problem of
cryptic error messages of loosely-typed languages.

But,if some types of mistakes are often made by users in R interactive
shell, I believe we should try to give more informative messages at
least for the mistakes.
I think the error I reported is one of the mistakes.

Unfortunately, I don't have ability to create a patch for it.
Hopefully, somebody to fix it soon for better R.

Daehyok Shin

On Wed, 2004-04-07 at 15:35, Tony Plate wrote:
> It's actually not that easy to provide the meaningful kind of error message 
> you are asking for.  (Though it would be nice.)
> Consider what happens in the case you give:
> (1) The argument of plot() of evaluated, and has the value NULL
> (2) plot() is called with a single argument, which is NULL
> All the information available inside plot() is that its argument has the 
> value NULL (without getting into meta programming).  However, it would be 
> possible for plot(), or xy.coords(), to print a more meaningful error 
> message like "called with NULL value for x".  This disadvantage of doing 
> this is that if you do it everywhere, a considerable volume of the code 
> becomes tests and error messages, which can make the code less readable and 
> more prone to errors (because of the possibility that some of the tests are 
> buggy themselves).  The weak type checking in the S language exacerbates 
> these problems.  As it currently is, many functions are simple and concise, 
> but provide very cryptic error messages when something goes wrong.  This is 
> the tradeoff.
> One might argue that x$z should cause an error, but it is a 
> long-established behavior that the "$" operator returns NULL when the list 
> element does not exist or is not uniquely identified (this might even be in 
> the written definition of the S language).
> It might be an interesting CS grad student project to build a system that 
> matches cryptic error messages and stack traces against a library of common 
> errors in order to provide less cryptic error messages.
> -- Tony Plate
> At Wednesday 01:07 PM 4/7/2004, Shin wrote:
> >When I tried the following commands, I got a strange message.
> >
> >
> > > x<-data.frame(y=c(1:10))
> > > plot(x$z)
> >Error in xy.coords(x, y, xlabel, ylabel, log) :
> >         x and y lengths differ
> >
> >"The data frame, x, does not have a field named z."
> >may be better user-friendly message for this kind of common error.
> >
> >
> >Daehyok Shin
> >
> >______________________________________________
> >R-help at stat.math.ethz.ch mailing list
> >https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

More information about the R-help mailing list