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
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@r-project.org m
2 matches
Mail list logo