[R] reshape cast to a sparse matrix?

Martin Maechler maechler at stat.math.ethz.ch
Thu Aug 16 10:47:56 CEST 2012


>>>>> Yin Aphinyanaphongs <yinnerspace at gmail.com>
>>>>>     on Tue, 14 Aug 2012 09:13:21 -0400 writes:

    > I am using the reshape package to convert a series of
    > values into a binary matrix. The binary matrix is very
    > sparse with many zeros and I'd like to use cast to
    > generate a sparse matrix using any of the sparse matrix
    > packages of choice. Is there functionality to support this
    > use?

Well, the Matrix package (part of every R) has several
convenient ways to construct sparse matrices,
depending on their (special) structure.

We mostly advertize   sparseMatrix()   which has
a large 'Examples' section.

If you want, you can contact me offline for more help,
but you'd definitely have to provide more details, and a
selfcontained example.

Martin Maechler, ETH Zurich,
one of the two 'Matrix' authors.

    > Are there strategies or other packages that that may be
    > useful?

    > Due to memory constraints, it would be best to convert to
    > sparse matrix on the fly rather than build the full matrix
    > and then convert it.

    > Thanks for the help, Yin



More information about the R-help mailing list