I have two vectors, let's say
a <- c('Q1', 'Q2', 'Q3')
and
b <- c('Q10', 'Q13', 'Q1', 'Q1', 'Q40', 'Q2', 'Q2', 'Q2')
Now I want to find the indices of the elements in a
in b
. So the result should be [3, 4, 6, 7, 8]
. I tried to to it with match(a, b)
, but this results in only the first occurrence of a
in b
so [3, 6]
.
Does anyone know how to do this in R?