Re: [R] looking for a faster way to compare two columns of a matrix

2010-09-24 Thread Michael Bedward
Hello Gustavo, Not sure if I've got all the details of your metric, but what about this... xx <- x[ , combn(5,2)] i <- seq(2, ncol(xx), 2) colSums(xx[,i-1] > xx[,i] & xx[,i] > 0) / colSums(xx[,i] > 0) Michael On 24 September 2010 02:53, Gustavo Carvalho wrote: > Please consider this matrix: >

[R] looking for a faster way to compare two columns of a matrix

2010-09-23 Thread Gustavo Carvalho
Please consider this matrix: x <- structure(c(5, 4, 3, 2, 1, 6, 3, 2, 1, 0, 3, 2, 1, 0, 0, 2, 1, 1, 0, 0, 2, 0, 0, 0, 0), .Dim = c(5L, 5L)) For each pair of columns, I want to calculate the proportion of entries different than 0 in column j (i > j) that have lower values than the entries in the s