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

I could put them in the same loop but this is slower.  The first for statement is fine.  It finds the matches and creates a list of the matches.  The second is too slow, it increments the sparse matrix elements.  

Let me know if I need to put in more complete code to make this understandable.



	[[alternative HTML version deleted]]

