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

>>>>> 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 

.

..

...

....  

.....

......

............ ---> Tada !! 


  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!

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