Displaying 2 results from an estimated 2 matches for "dacc2".
Did you mean:
acc2
2011 Jul 12
1
Avoiding loops to detect number of coincidences
...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]]
2011 Jul 12
1
Creating a zero matrix when a condition doesn´t get it
Hi all,
I first create a matrix/data frame called "d2" if another matrix
accomplishes some restrictions "dacc2"
da2<-da1[colSums(dacc2)>9,]
da2<-da2[(da2[,13]=24),]
write.csv(da2, file =paste('hggi', i,'.csv',sep = ''))
The thing is if finally da2 cannot get/passs the filters, it cannot writte a
csv because there is no any true condition.
How can I create anyway a cs...