z=c("abcD9","recde6","7gfbe","dvS1","MNM09")
d=c("abcD9","recde6","abcD9","bgfh123","dvS1")
y <- numeric(length=25)
k<-1
for ( i in 1:5) {
for (j in 1:5) {
a <- (z[i]==d[j])
if( a==TRUE) y[k] <- j else y[k] <- 0
}
k<-k+1
}
我应该将结果作为“y”作为向量 (1 0 3 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0)