From maechler at stat.math.ethz.ch  Fri Dec  2 17:56:31 2005
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Fri, 2 Dec 2005 17:56:31 +0100
Subject: [Rd] t() dropping NULL dimnames {was "all.equal() for mismatching
	names..."}
In-Reply-To: <17296.20406.853935.686989@stat.math.ethz.ch>
References: <17296.8817.937646.30624@bossiaea.maths.uwa.edu.au>
	<17296.20406.853935.686989@stat.math.ethz.ch>
Message-ID: <17296.31935.139175.48521@stat.math.ethz.ch>

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

>>>>> "BeT" == Berwin A Turlach <berwin at 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....

Martin



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