Ramzi Feghali wrote:


Hello Mr Ripley,

Whom is this mail adressed to? The mailing list R-help or Professor Ripley?



i was waiting you to ask and if you don't mind if there is a fast way in R to do these loops made with R and that takes a week because my matrix is with thousand of rows.
I got another method that is more fast and is utilised by many packages : interfacing with other languages", but it is only a question for information

So you are going to optimize the following code?



foo<-function()
{for (i in 1:(n-1)){
for (k in (i+1):n){ b_0
for (j in 1:m){
if(bin[i,j]==TRUE&bin[k,j]==TRUE) b_b+1}
print (b)
} }
}


Thanks a lot
Ramzi

There seems to be a logical n x m matrix called bin. And the sollution of your problem should be solved within seconds by

bin %*% t(bin)

where the upper triangular matrix of the result consists of the results for all i and k in your loops.

Uwe Ligges

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to