unique(NULL)

Douglas Bates bates@stat.wisc.edu
Tue, 17 Feb 1998 11:30:42 -0600 (CST)


I spent a while chasing this one down!

In S
 S> unique(NULL)
 NULL
whereas in R (both 0.61.1 and yesterday's 0.62-snapshot)
 > unique(NULL)
 Error: duplicated applies only to vectors

I think I prefer the behaviour in S.

Although there is code in the do_duplicated function in
		       $RHOME/src/main/unique.c
to handle the case of zero-length vectors it appears that the check
for isVector(x) immediately before that is what is causing the
problem.

Would it be as simple as changing the check on
 if (!isVector(x))
to
 if (!(isVector(x) || isNull(x)))
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._