title: Is there an R function for finding the index of an element in a vector?
body: <p>In R, I have an element <code>x</code> and a vector <code>v</code>. I want to find the first index of an element in <code>v</code> that is equal to <code>x</code>. I know that one way to do this is: <code>which(x == v)[[1]]</code>, but that seems excessively inefficient. Is there a more direct way to do it?</p>
  
  <p>For bonus points, is there a function that works if <code>x</code> is a vector? That is, it should return a vector of indices indicating the position of each element of <code>x</code> in <code>v</code>.</p>