[R] Scaling rows of a large Matrix::sparseMatrix()

Stefan Evert stefanML at collocations.de
Wed Jan 13 09:07:24 CET 2016


> On 13 Jan 2016, at 02:50, tomdharray at gmail.com wrote:
> 
> So my question is: How can the rows of a large sparse matrix be
> efficiently scaled?

If you're not picky about the particular storage format, the "wordspace" package

	http://wordspace.r-forge.r-project.org/

has an efficient scaleMargins() function, which can be made to do what you need in combination with rowNorms() and colNorms(); cf. the trivial implementation of normalize.rows().

These functions only work with a dgCMatrix and will try to coerce any other sparseMatrix to this format.

Best,
Stefan



More information about the R-help mailing list