Use match
:
match(PDBRenum.3V5Q[,2], PDBXPoly.3V5Q[[1]][,3])
With match(x,y)
, the ith element of the output is the first index of y
that matches x[i]
, unless x[i]
doesn't appear in y
, in which case it gives NA
.
match
is most useful when y
has no repeated values.
For example:
> match( c(1,3,5), c(2,6,7,3,1) )
[1] 5 4 NA
> match( c(1,3,5), c(2,6,7,3,1, 8,1,3) )
[1] 5 4 NA
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…