Re: [R] how to replace my double for loop which is little efficient!

2010-12-27 Thread bbslover
Thank Berend, It seems like that it is better to attach a PDF file for avoiding messy code. Yes, I want to obtain is Tanimoto coefficient and your web site "wikipedia" is about this coefficient. I also search R site about tanimoto coefficient and learn it more. About your code, I has saved and

Re: [R] how to replace my double for loop which is little efficient!

2010-12-27 Thread Berend Hasselman
Found this: http://en.wikipedia.org/wiki/Jaccard_index#Tanimoto_coefficient_.28extended_Jaccard_coefficient.29 and an R site search with "tanimoto" yielded some more interesting stuff. The rest is up to you. Berend -- View this message in context: http://r.789695.n4.nabble.com/how-to-replac

Re: [R] how to replace my double for loop which is little efficient!

2010-12-27 Thread Berend Hasselman
bbslover wrote: > > thanks for your help. I am sorry I do not full understand your code, so i > can not correct using your code to my data. here is the attachment of my > data, and what I want to compute is the equation in the word document of > the attachment: > > the code form Berend can get

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread Berend Hasselman
djmuseR wrote: > > On Sun, Dec 26, 2010 at 4:18 AM, bbslover wrote: > >> >> x: is a matrix 202*263, that is 202 samples, and 263 independent >> variables >> >> num.compd<-nrow(x); # number of compounds >> diss.all<-0 >> for( i in 1:num.compd) >> for (j in 1:num.compd) >> if (i!=j) { >

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread bbslover
thanks for your help. I am sorry I do not full understand your code, so i can not correct using your code to my data. here is the attachment of my data, and what I want to compute is the equation in the word document of the attachment: the code form Berend can get the answer i want to get. http:

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread bbslover
thanks for your help, it is great. In addition, In the beginning, the format of x is dataframe, and i run my code, it is so slow, after your help, I change x for matirx, it is so quick. I am very grateful your kind help, and your code is so good! kevin -- View this message in context: http://r.

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread Dennis Murphy
Hi: On Sun, Dec 26, 2010 at 4:18 AM, bbslover wrote: > > Dear all, > > My double for loop as follows, but it is little efficient, I hope all > friends can give me a "vectorized" program to replace my code. thanks > > x: is a matrix 202*263, that is 202 samples, and 263 independent > variables

Re: [R] how to replace my double for loop which is little efficient!

2010-12-26 Thread Berend Hasselman
bbslover wrote: > > x: is a matrix 202*263, that is 202 samples, and 263 independent > variables > > num.compd<-nrow(x); # number of compounds > diss.all<-0 > for( i in 1:num.compd) >for (j in 1:num.compd) > if (i!=j) { > S1<-sum(x[i,]*x[j,]) > S2<-sum(x[i,]^2) >

[R] how to replace my double for loop which is little efficient!

2010-12-26 Thread bbslover
Dear all, My double for loop as follows, but it is little efficient, I hope all friends can give me a "vectorized" program to replace my code. thanks x: is a matrix 202*263, that is 202 samples, and 263 independent variables num.compd<-nrow(x); # number of compounds diss.all<-0 for( i in 1:nu