Is there an R function for finding the index of an element in a vector?
The function match works on vectors: match only returns the first encounter of a match, as you requested. It returns the position in the second argument of the values in the first argument. For multiple matching, %in% is the way to go: %in% returns a logical vector as long as the first argument, with a … Read more