SCM

[#6781] show, format and/or print methods give error for large dimensional sparse matrices with NA's for dimnames

Date:
2022-10-04 11:58
Priority:
3
State:
Closed
Submitted by:
Luc van Schijndel (luckylluck2)
Assigned to:
Nobody (None)
Hardware:
None
Product:
None
Operating System:
All
Component:
None
Version:
None
Severity:
trivial
Resolution:
None
URL:
Summary:
show, format and/or print methods give error for large dimensional sparse matrices with NA's for dimnames

Detailed description
#throws no error with small dimensions, works fine
Matrix::sparseMatrix(i = c(1,1,2), j = c(2,3,3), x = 1:3, dims = c(3,3), dimnames = list(rep(NA, 3), rep(NA, 3)))

#throws an error:
Matrix::sparseMatrix(i = c(1,1,2), j = c(2,3,3), x = 1:3, dims = c(100, 100), dimnames = list(rep(NA, 100), rep(NA, 100)))

#OUTPUT:
# 100 x 100 sparse Matrix of class "dgCMatrix"
# Error in if (msg.if.not.empty && is.list(dn) && length(dn) >= 2 &&
# is.character(cn <- dn[[2]]) && :
# missing value where TRUE/FALSE needed

My guess is that the format() method throws the error, since we do get the description of the object: '100 x 100 sparse Matrix of class "dgCMatrix"'

Comments:

Message  ↓
Date: 2022-10-12 17:53
Sender: Mikael Jagan

Thanks - the problem was in Matrix:::emptyColnames(), called by format(), etc. when a matrix is wide enough that column names are suppressed. Should be fixed now, with r6781. You can test by installing latest Matrix:

> install.packages("Matrix", repos = "http://R-Forge.R-project.org";)

You might need type = "source", as the build hasn't finished yet.

Attached Files:

Changes

Field Old Value Date By
status_idOpen2022-10-12 17:53jaganmn
close_dateNone2022-10-12 17:53jaganmn
Thanks to:
Vienna University of Economics and Business Powered By FusionForge