From: <daniel_at_sintesys.com.ar>

Date: Thu 01 Jul 2004 - 04:28:47 EST

ret<-cbind(a,b,c,d);

ret

}

ret}

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 01 04:33:05 2004

Date: Thu 01 Jul 2004 - 04:28:47 EST

Hi,

I´m new in R. I´m working with similarity coefficients for clustering
items. I created one function (coef), to calculate the coefficients from
two pairs of vectors and then, as an example, the function
simple_matching,

taking a data.frame(X) and using coef in a for cicle.
It works, but I believe it is a bad way to do so (I believe the for cicle
is not necessary). Somebody can suggest anything better.
Thanks

Daniel Rozengardt

coef<-function(x1,x2){a<-sum(ifelse(x1==1&x2==1,1,0));

b<-sum(ifelse(x1==1&x2==0,1,0)); c<-sum(ifelse(x1==0&x2==1,1,0)); d<-sum(ifelse(x1==0&x2==0,1,0));

ret<-cbind(a,b,c,d);

ret

}

simple_matching<-function(X) {

ret<-matrix(ncol=dim(X)[1],nrow=dim(X)[1]);
diag(ret)<-1;

for (i in 2:length(X[,1])) {

for (j in i:length(X[,1])) { vec<-coef(X[i-1,],X[j,]); result<-(vec[1]+vec[3])/sum(vec); ret[i-1,j]<-result; ret[j,i-1]<-result}};

ret}

R-help@stat.math.ethz.ch mailing list

https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Jul 01 04:33:05 2004

*
This archive was generated by hypermail 2.1.8
: Fri 18 Mar 2005 - 08:10:21 EST
*