Hello, I would like to read and write sparse matrices using the functions write.matrix.csr() and read.matrix.csr() of the package e1071. Writing is OK but reading back the matrix fails: x <- rnorm(100) m <- matrix(x, 10) m[m < 0.5] <- 0 m.csr <- as.matrix.csr(m) write.matrix.csr(m, "sparse.dat") read.matrix("sparse.dat") Error in initialize(value, ...) : Can't use object of class "integer" in new(): Class "matrix.csr" does not extend that class Is something wrong with the code above or it must be considered as a bug? Best regards, Peter
Don't you want read.matrix.csr not read.matrix? url: www.econ.uiuc.edu/~roger Roger Koenker email rkoenker at uiuc.edu Department of Economics vox: 217-333-4558 University of Illinois fax: 217-244-6678 Champaign, IL 61820 On Jan 28, 2005, at 9:22 AM, Jeszenszky Peter wrote:> Hello, > > I would like to read and write sparse matrices using the > functions write.matrix.csr() and read.matrix.csr() > of the package e1071. Writing is OK but reading back the > matrix fails: > > x <- rnorm(100) > m <- matrix(x, 10) > m[m < 0.5] <- 0 > m.csr <- as.matrix.csr(m) > write.matrix.csr(m, "sparse.dat") > read.matrix("sparse.dat") > > Error in initialize(value, ...) : Can't use object of class "integer" > in new(): Class "matrix.csr" does not extend that class > > Is something wrong with the code above or it must be > considered as a bug? > > Best regards, > > Peter > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html
This is a bug, thanks for pointing this out. Fixed for the next release of e1071. David ----------------- Hello, I would like to read and write sparse matrices using the functions write.matrix.csr() and read.matrix.csr() of the package e1071. Writing is OK but reading back the matrix fails: x <- rnorm(100) m <- matrix(x, 10) m[m < 0.5] <- 0 m.csr <- as.matrix.csr(m) write.matrix.csr(m, "sparse.dat") read.matrix("sparse.dat") Error in initialize(value, ...) : Can't use object of class "integer" in new(): Class "matrix.csr" does not extend that class Is something wrong with the code above or it must be considered as a bug? Best regards, Peter