Skip to content
Prev 61973 / 63424 Next

dim<-() changed in R-devel; no longer removing "dimnames" when doing dim(x) <- dim(x)

Hello,

the fix of PR18612 (https://bugs.r-project.org/show_bug.cgi?id=18612)
in r85380 (https://github.com/wch/r-source/commit/2653cc6203fce4c48874111c75bbccac3ac4e803)
caused a change in `dim<-()`.  Specifically, in the past, any
`dim<-()` assignment would _always_ remove "dimnames" and "names"
attributes per help("dim"):

    The replacement method changes the "dim" attribute (provided the
new value is compatible) and removes any "dimnames" and "names"
attributes.

In the new version, assigning the same "dim" as before will no longer
remove "dimnames".  I'm reporting here to check whether this change
was intended, or if it was an unintended side effect of the bug fix.

For example, in R Under development (unstable) (2023-10-21 r85379), we
would get:
List of 2
 $ : chr "A"
 $ : chr [1:2] "a" "b"
NULL


whereas in R Under development (unstable) (2023-10-21 r85380) and
beyond, we now get:
List of 2
 $ : chr "A"
 $ : chr [1:2] "a" "b"
List of 2
 $ : chr "A"
 $ : chr [1:2] "a" "b"
NULL

/Henrik