title: Check if the element belongs to a vector and get its indices in R
body: <p>I want to know if an element belongs to a vector in R. I can do it with <code>%in%</code>, right? However, I also want to know the indices of all the examples of this element, and I want these indices as a vector as well. For example,</p>
  
  <pre><code>x&lt;-c(1,3,5,5,7,5,8,9,0,5)
  
  y&lt; - myCoolFunction (x, 5)
  </code></pre>
  
  <p>y should be equal [3,4,6,10], because that's where 5 is in x.</p>
  
  <p>I know how to do it <strong>algorithm-wise</strong> (with ifs and loops etc.), my questions is: is there an elegant R-style function to do it? Or a combination of two?</p>