Re: [R] incrementing matrix elements more efficiently

2010-08-15 Thread Romain Francois
Le 15/08/10 02:43, david h shanabrook a écrit : I need to increment cells of a matrix (collusionM). The indexes to increment are in an index (matchIndex). This is sample code library(seqinr) library(Matrix) x- abcabcabc mx- s2c(x) collisionM- Matrix(0,nrow=10, ncol=10,

[R] incrementing matrix elements more efficiently

2010-08-14 Thread david h shanabrook
I need to increment cells of a matrix (collusionM). The indexes to increment are in an index (matchIndex). This is some of the code for (j in 1:(rows-1)) matchIndex[[j]] - which(mx[j]==mx) for (j in 1:(rows-1)) collisionM[j,matchIndex[[j]]] - collisionM[j,matchIndex[[j]]] + 1

[R] incrementing matrix elements more efficiently

2010-08-14 Thread david h shanabrook
I need to increment cells of a matrix (collusionM). The indexes to increment are in an index (matchIndex). This is sample code library(seqinr) library(Matrix) x - abcabcabc mx - s2c(x) collisionM - Matrix(0,nrow=10, ncol=10, sparse=TRUE) matchIndex - list() rows -