[Rd] all.equal(, ) not considering names [was "vector
documentation error?"]
Tony Plate
tplate at blackmesacapital.com
Fri Jul 23 16:45:59 CEST 2004
At Wednesday 09:08 AM 7/21/2004, Martin Maechler wrote:
> >>>>> "Spencer" == Spencer Graves <spencer.graves at pdf.com>
> >>>>> on Wed, 21 Jul 2004 05:47:01 -0700 writes:
>
> Spencer> The help file for "vector" in R 1.9.1 for Windows includes the
> Spencer> following:
>
> Spencer> x <- c(a = 1, b = 2)
> Spencer> is.vector(x)
> Spencer> as.vector(x)
> Spencer> all.equal(x, as.vector(x)) ## FALSE
>
> Spencer> I ran this just now and got TRUE.
>
>yes, I get this as well {R-patched on Linux}.
>
>I'm sure that it never returned FALSE, since all.equal()
>doesn't ever. However it *did* give non TRUE
>in R versions up to 1.6.2 :
>
> > x <- c(a=1,b=2); all.equal(x, as.vector(x))
> [1] "names for target but not for current" "TRUE"
>
>and it does give something similar in the our S-plus 6.1 version.
>
>Our documentation does nowhere specify what should happen
>exactly in this case, but I do doubt that the current behavior
>is correct.
>What do other (long time S language) users think?
Sometimes I want one thing, sometime the other. What I generally do when I
need a test for equivalence is construct one, by trial and error, that
works for the situation at hand, since the documentation for these types of
things in various implementations of the S-language tends to be not
comprehensive. So, above all, I don't want the behavior to change.
The current behavior in R seems to vaguely follow the spirit of the
documentation for all.equal, which emphasizes approximation in numeric
comparisons, and ignores the issues of names (which is just what the
current implementation of the function does too). It might be nice to have
an argument ignore.names that is passed down recursively, but that would
probably be difficult to add since all.equal is a generic function.
I'd argue for the documentation being updated to reflect the current
behavior (i.e., ignore names).
-- Tony Plate
More information about the R-devel
mailing list