Re: [R] Sparse matrix performance question

2010-12-07 Thread Douglas Bates
On Mon, Dec 6, 2010 at 1:11 PM, scott white wrote: > Btw, forgot to mention I am using the standard Matrix package and I am > running version 2.10.1 of R. > > On Mon, Dec 6, 2010 at 11:04 AM, scott white > wrote: > >> I have a very sparse square matrix which is < 20K rows & columns and I am >> tr

Re: [R] Sparse matrix performance question

2010-12-06 Thread scott white
Btw, forgot to mention I am using the standard Matrix package and I am running version 2.10.1 of R. On Mon, Dec 6, 2010 at 11:04 AM, scott white wrote: > I have a very sparse square matrix which is < 20K rows & columns and I am > trying to row standardize the matrix for the rows that have non-mis

[R] Sparse matrix performance question

2010-12-06 Thread scott white
I have a very sparse square matrix which is < 20K rows & columns and I am trying to row standardize the matrix for the rows that have non-missing value as follows: row_sums <- rowSums(M,na.rm=TRUE) nonzero_idxs <- which(row_sums>0) nonzero_M <- M[nonzero_idxs,]/row_sums[nonzero_idxs] M[nonzero_idx