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

2016-01-13 Thread Gerrit Eichner
Hello, Dirk, maybe I'm missing something, but to avoid your for-loop-approach doesn't M <- M/Matrix::rowSums(M) do what you want? Hth -- Gerrit - Dr. Gerrit Eichner Mathematical Institute, Room 212

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

2016-01-13 Thread Stefan Evert
> On 13 Jan 2016, at 02:50, tomdhar...@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

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

2016-01-13 Thread tomdharray
Hello Gerrit, Thanks. Your proposal works in general, but I get memory allocation errors with my actual 57,000 x 14,000 matrix. The fix which I now use is to scale the data before I build the matrix; see below. Cheers, Dirk ## Code Start - library(parallel)

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

2016-01-12 Thread tomdharray
Hello R-Users, I'm looking for a way to scale the rows of a sparse matrix M with about 57,000 rows, 14,000 columns, and 238,000 non-zero matrix elements; see example code below. Usually I'd use the base::scale() function (see sample code), but it freezes my computer. The same happens when I try