[R] working with sparse matrix

davefrederick zorluhan at gmail.com
Tue Jun 21 15:48:24 CEST 2011


Hi, I have a 500x 53380 sparse matrix and I am trying to dichotomize it.
Under sna package I have found event2dichot yet it doesnt recognize sparse
matrix and requires adjacency matrix or array. I tried to run a simple loop
code 

for (i in 1:500) 
for (j in 1:53380) 
if (matrix[i,j]>0) matrix[i,j]=1

yet this takes a lot of time to run, I mean it has been last two hours and
it is stil running.

I am wondering if there is a shortcut or a hack here someone can recommend.

thanks all.

--
View this message in context: http://r.789695.n4.nabble.com/working-with-sparse-matrix-tp3614117p3614117.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list