[R] Using grep

mentor_ mentor_ at gmx.net
Wed Oct 8 17:19:02 CEST 2008


I have a vector A with (200, 201, 202, 203, 204, ... 210) and a vector B
with (201, 204, 209).
Now I would like to get the position in vector A matches with the entries in
vector B
So what I want to have is the following result:
[1] 2 5 10

I tried the following:
grep(B, A)

grep(c(B), A)

A <- as.character(A)
B <- as.character(B)

grep(B, A)
grep(c(B), A)

and several other combinations. But nothing is giving me the right result?!
Does anyone know why?

View this message in context: http://www.nabble.com/Using-grep-tp19881017p19881017.html
Sent from the R help mailing list archive at Nabble.com.

More information about the R-help mailing list