From maechler at ion-3.math.ethz.ch  Thu Apr 30 23:39:48 2015
From: maechler at ion-3.math.ethz.ch (Martin Maechler)
Date: Thu, 30 Apr 2015 23:39:48 +0200
Subject: [Rd] dimnames returned by function apply
In-Reply-To: <21826.22302.30563.549567@stat.math.ethz.ch>
References: <99ED4CB4-AF79-421F-B7A0-3BBFB8F5FCD6@dkfz.de>
	<21826.22302.30563.549567@stat.math.ethz.ch>
Message-ID: <21826.41252.233170.851695@stat.math.ethz.ch>

>>>>> Martin Maechler <maechler at lynne.stat.math.ethz.ch>
>>>>>     on Thu, 30 Apr 2015 18:23:58 +0200 writes:

>>>>> Fischer, Bernd <b.fischer at dkfz-heidelberg.de>
>>>>>     on Wed, 29 Apr 2015 20:22:44 +0200 writes:

    >> Dear all, I noticed that the dimnames returned by apply
    >> are different in the new release.

    >> In the following example. The returned row-names are
    >> c(?S?,?T?), but shouldn?t they be c(?X?,?Y?) as in the
    >> old release?

    > Not quite : They were c("X.S", "Y.T")

    > Still

    [............]

    >   Congratulations on your finding the first "bad" bug in R
    > 3.2.0 !  "bad": a true regression, i.e., a bug not present
    > in earlier versions of R.

    > I'm almost sure it is my fault, and I'm going to look into
    > fixing it!

Fix committed to R-devel and R-patched, svn revision 
68282 and 68283, respectively.

So if you get R 3.2.0 patched in a day or so, you'll get a
version of apply() which behaves as previously in this case.

Martin Maechler


    > For the curious ones: It was introduced with the following
    > new feature (which implied fixing apply()'s treatment of
    > named dimnames):

    >     ? apply(m, 2, identity) is now the same as the matrix
    > m when it has _named_ row names.

    >> Best, Bernd

    > Thank you, Bernd, for the report!

    > Martin Maechler, ETH Zurich


    >>> X = array(1:8, dim=c(4,2)) dimnames(X) =
    >>> list(c("A","B","C","D"),c("S","T")) apply(X, 1,
    >>> function(x) { c(X=x[1]*5,Y=x[2]*5) } )

    >> A B C D S 5 10 15 20 T 25 30 35 40

    >>> sessionInfo()
    >> R version 3.2.0 (2015-04-16)

    >     [...........]



[Rd] dimnames returned by function apply
Martin Maechler