[Rd] t() dropping NULL dimnames {was "all.equal() for mismatching names..."}

From: Martin Maechler <maechler_at_stat.math.ethz.ch>
Date: Fri 02 Dec 2005 - 16:56:31 GMT

>>>>> "MM" == Martin Maechler <maechler@stat.math.ethz.ch>
>>>>> on Fri, 2 Dec 2005 14:44:22 +0100 writes:

>>>>> "BeT" == Berwin A Turlach <berwin@maths.uwa.edu.au>
>>>>> on Fri, 2 Dec 2005 18:31:13 +0800 writes:

    BeT> First, I recently had reasons to read the help page of as.vector() and     BeT> noticed in the example section the following example:

    BeT> x <- c(a = 1, b = 2)
    BeT> is.vector(x)
    BeT> as.vector(x)
    BeT> all.equal(x, as.vector(x)) ## FALSE

   MM> actually 'FALSE' was never the case, but "non-TRUE" once was, see below.

    BeT> However, in all versions of R in which I executed this example, the
    BeT> all.equal command returned TRUE which suggest that either the comment
    BeT> in the help file is wrong or the all.equal/as.vector combination does
    BeT> not work as intended in this case.  For the former case, I attach
    BeT> below a patch which would fix vector.Rd.

    MM> We recently had the following posting on R-devel
    MM> https://stat.ethz.ch/pipermail/r-devel/2005-October/034962.html
    MM> (Subject: [Rd] all.equal() improvements (PR#8191))
    MM> where Andrew Piskorsky proposed a (quite
    MM> extensive) patch to all.equal() in order to make sure that     MM> things like names must match for all.equal() to return TRUE.

I'm testing the first part of Andy's proposition {the 2nd part was about making the result strings more informative for  the case where all.equal() does *not* return TRUE}.

Interestingly, it did break 'make check' and because of a somewhat subtle reason;
something we could consider an other (typically inconsequential) inconsistency :

t() drops dimnames when they are list(NULL,NULL) and has been doing so at least since R version 1.0.0 :

 x <- cbind(1:2, 2:1); dimnames(x) <- list(NULL, NULL)  identical(x, t(x)) ## -> FALSE !
 str(t(x)) # "no dimnames" (i.e. dimnames(x) === NULL)

Now I'm looking into changing that one....


R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat Dec 03 10:31:50 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:34 GMT