[R] Matrix package: writeMM

Douglas Bates bates at stat.wisc.edu
Thu May 17 17:03:58 CEST 2007


On 5/15/07, Jose Quesada <quesada at gmail.com> wrote:
> Hi,
>
> I'm finding that readMM() cannot read a file written with writeMM().
> Example:
>
> library(Matrix)
> a = Matrix(c(1,0,3,0,0,5), 10, 10)
> a = as(a, "CsparseMatrix")
> writeMM(a, "kk.mm")
> b = readMM("kk.mm")
>
> Error in validObject(.Object) : invalid class "dgTMatrix" object: all row
> indices must be between 0 and nrow-1

You're right (and thanks for including a reproducible example).  The
writeMM function is writing 0-based indices when they should be
1-based.  Thanks for bringing this to our attention.  It's rather
embarrassing that we didn't create such a test and discover it for
ourselves.

This will be fixed in the next release.



More information about the R-help mailing list