[R] dput sparseMatrix list

David Winsemius dwinsemius at comcast.net
Tue Jan 5 08:30:47 CET 2016


> On Jan 4, 2016, at 11:17 PM, Lietz, Haiko <Haiko.Lietz at gesis.org> wrote:
> 
> hi all,
> 
> when dputting a list of sparse matrices (Matrix package), the output does not contain the data but the information that the list contains sparse matrices.
> 
> M <- sparseMatrix(i = c(2, 1), j = c(1, 2), x = c(1, 1))
> 
> dput(M) ... works.
> 
> dput(list(M, M)) ... does not work.
> 
> how can I dput a list of sparse matrices?

> MM <- list(M,M)
> dput(MM)
list(<S4 object of class structure("dgCMatrix", package = "Matrix")>, 
    <S4 object of class structure("dgCMatrix", package = "Matrix")>)

No problem.

I do get an error (clarifying the "did not work" statement), as (perhaps) did you?

> dput(M,M)
Error in cat("new(\"", clx, "\"\n", file = file, sep = "") : 
  invalid connection

Perhaps the `dput` function was not configured to handle two S4 objects in  a list?

> [[alternative HTML version deleted]]

Please do better next time.

> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

David Winsemius
Alameda, CA, USA



More information about the R-help mailing list