[R] pair-wise computation of columns in a matrix

2014-01-26 Thread Kathryn Lord
Dear R users, I'd like to compute rho(looks like a correlation matrix) with every two columns of uu matrix below. Toy example, uu - matrix(1:15, nr=3, nc=5) uu [,1] [,2] [,3] [,4] [,5] [1,]147 10 13 [2,]258 11 14 [3,]369 12 15 rho -

Re: [R] pair-wise computation of columns in a matrix

2014-01-26 Thread arun
Hi, Try:  indx- combn(ncol(uu),2) sapply(seq_len(ncol(indx)),function(i) rho(uu[,indx[1,i]],uu[,indx[2,i]])) # [1] 0.9746318 0.9594119 0.9512583 0.9462555 0.9981909 0.9961499 0.9946367 # [8] 0.9996186 0.9990560 0.9998746 A.K. On Sunday, January 26, 2014 10:04 AM, Kathryn Lord