SCM

[#6783] Matrix:cov2cor now drops dimnames

Date:
2022-10-23 16:10
Priority:
3
State:
Closed
Submitted by:
Ben Bolker (bbolker)
Assigned to:
Martin Maechler (mmaechler)
Hardware:
None
Product:
None
Operating System:
All
Component:
None
Version:
None
Severity:
None
Resolution:
Fixed
URL:
Summary:
Matrix:cov2cor now drops dimnames

Detailed description
Package version 1.5.2 (devel). I assume this is related to the new name-dropping behaviour when scaling by diagonals, but is new and presumably unintended?


```
m <- diag(1:3)
dimnames(m) <- list(LETTERS[1:3], letters[1:3])
dimnames(cov2cor(m))
library(Matrix)
M <- as(m, "denseMatrix")
dimnames(cov2cor(M))
M2 <- as(m, "sparseMatrix")
dimnames(cov2cor(M2))
```

Comments:

Message  ↓
Date: 2022-10-31 17:06
Sender: Martin Maechler

This has been fixed (already on Oct 10, svn r3705)

Date: 2022-10-24 15:47
Sender: Martin Maechler

Thank you, Ben.

Note that for previous (incl current) versions of {Matrix},
your last function call gives for me (several versions of R with respective versions of Matrix via library(Matrix, .Library) :

> dimnames(cov2cor(M2))
Error in asMethod(object) :
matrix is not symmetric; consider forceSymmetric() or symmpart()

Also note that your first call did (in several earlier versions) return *symmetrized* dimnames so was *also* not base R - compatible {which does not have formal symmetric matrices} but rather returned

> cov2cor(M) # a b c for *both* dimensions
3 x 3 Matrix of class "dpoMatrix"
a b c
a 1 0 0
b 0 1 0
c 0 0 1
>
---------------

Still the 1.5-2 behavior *is* a regression because when the matrix m has symmetric dimnames, they should definitely be kept .. and they are not.
I'm testing a fix (for Matrix 1.5-3 which will have to wait a bit ..).



Attached Files:

Changes

Field Old Value Date By
status_idOpen2022-10-31 17:06mmaechler
close_dateNone2022-10-31 17:06mmaechler
ResolutionAccepted As Bug2022-10-31 17:06mmaechler
assigned_tonone2022-10-24 15:47mmaechler
Operating SystemNone2022-10-24 15:47mmaechler
ResolutionNone2022-10-24 15:47mmaechler
Thanks to:
Vienna University of Economics and Business Powered By FusionForge