R-alpha: jpn() port

Kurt Hornik Kurt.Hornik@ci.tuwien.ac.at
Mon, 14 Apr 1997 10:04:34 +0200

>>>>> Peter Dalgaard BSA writes:

> Kurt Hornik <Kurt.Hornik@ci.tuwien.ac.at> writes:
>> Finally, here's something that's also been on my mind for some time now
>> (and also needed help in the port).  Code like
>> if(all(names(x)) == c("x", "y"))
>> fails if names(x) is NULL.  Is that really necessary?  (More precisely,
>> obviously we only want to test whether the two objects have equal
>> values, a la Lisp `equal').

> According to my parenthesis count, that expression will fail in any
> case!

Yes ... I meant

	if(all(names(x) == c("x", "y")))

> However, I get your drift. Splus has
>> all(NULL)
> [1] T
>> any(NULL)
> [1] F

> Which makes sense for cases like yours. R should probably conform to
> this.

Actually, I am not sure about that, but it does not solve the problem.
If you look at the code in the S jpn package, it contains

	if(all(names(region) == c("x", "y")))

If region has no names attribute,

	all(names(region) == c("x", "y"))

gives NA and if(NA) (correctly) gives ``Error: Missing value where
logical needed''.  The problem is that NULL == something gives NA.
(Should it really do that?)

But perhaps it is better anyway to force the programmer to check for
NULL values before comparisons ...


r-devel 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-devel-request@stat.math.ethz.ch