Hi all, I have this information on a file ht.txt, imagine it is a data frame without labels:
1 1 1 8 1 1 6 4 1 3 1 3 3 And on other table called "pru.txt" I have sequences similar this 4 1 1 8 1 1 6 4 1 3 1 3 3 1 6 1 8 1 1 6 4 1 3 1 3 3 1 1 1 8 1 1 6 4 1 3 1 3 3 6 6 6 8 1 1 6 4 1 3 1 3 3 I want to now how many positions are identical between each row in pru compared with ht. n and m are the col and row of pru (m is the same number in pru and ht) I tried this with loops n<-nrow(pru) m<-ncol(pru) dacc2<-mat.or.vec(n, m) for (g in 1:n){ for (j in 1:m){ if(pru[g,j]-ht[1,j]!=0) dacc2[g,j]=0 else {dacc2[g,j]=1} } } So when I have dacc2 I can filter this: dar2<-pru[colSums(dacc2)>2 & colSums(dacc2)<10,] There is some way to avoid loops? [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.