Is this what you want:
> set.seed(1)
> x <- sample(letters,15)
> y <- sample(letters,15)
> z <- intersect(x,y)
> # find index in x
> match(z, x)
[1] 1 4 5 8 9 12 13 15> # index in y
> match(z,y)
[1] 11 10 7 1 14 9 5 3>
> z
[1] "g" "u" "e" "m" "l"
"c" "y" "x"> x
[1] "g" "j" "n" "u" "e"
"s" "w" "m" "l" "b"
"d" "c" "y" "v"
"x"> y
[1] "m" "r" "x" "i" "y"
"t" "e" "z" "c" "u"
"g" "a" "f" "l"
"q">
On Sun, Aug 9, 2009 at 8:04 PM, Praveen
Surendran<praveen.surendran at ucd.ie> wrote:> Hi all,
>
>
>
> Is there a way to get the index of elements in intersect(x,y) where x and y
> are vectors with few common elements.
>
>
>
> Appreciate your response.
>
>
>
> Praveen Surendran.
>
>
>
>
> ? ? ? ?[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?