[Rd] dimnames returned by function apply

Martin Maechler maechler at lynne.stat.math.ethz.ch
Thu Apr 30 18:23:58 CEST 2015


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

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



More information about the R-devel mailing list