Re: [R] efficient matrix element comparison

2010-08-08 Thread Nikhil Kaza
How about a <- which(row(matchM)!=matchM) b <- matchM[a] diag(collusionM[a,b]) <-1 Nikhil Kaza Asst. Professor, City and Regional Planning University of North Carolina nikhil.l...@gmail.com On Aug 8, 2010, at 8:43 PM, david h shanabrook wrote: It is a simple problem in that I simply want to

Re: [R] efficient matrix element comparison

2010-08-08 Thread Henrique Dallazuanna
Try this: Matrix(diag(duplicated(matchM)), sparse = TRUE) On Sun, Aug 8, 2010 at 9:43 PM, david h shanabrook wrote: > It is a simple problem in that I simply want to convert the For loop to a > more efficient method. It simply loops through a large vector checking if > the numeric element is no

[R] efficient matrix element comparison

2010-08-08 Thread david h shanabrook
It is a simple problem in that I simply want to convert the For loop to a more efficient method. It simply loops through a large vector checking if the numeric element is not equal to the index of that element. The following example demonstrates a simplified example: > rows <- 10 > collusionM