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
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
2 matches
Mail list logo