Assume two character, A and B:
A <- c("A", "B", "B", NA, "D2", "K")
B <- c("A", "B", "C", "D1", "D2", "E", "F", "K", "L")
While B only contains unique entries, elements in A don't have to be unique.
Now I'd like to get the indices of the elements in A as they appear in B, except for NAs. Thus, in the example above, R function should return
1 2 2 5 8
Thanks a lot in advance!