title: R - Filter a vector using a function
body: <p>I have a function similar to this one:</p>
  
  <pre><code>isGoodNumber &lt;- function(X) 
  {
  if (X==5) return(TRUE) else return(FALSE)
  }
  
  I have a vector:
  v&lt;-c(1,2,3,4,5,5,5,5)
  </code></pre>
  
  <p>I want to obtain a new vector that contains the elements of <code>v</code> where <code>isGoodNumber(v) == TRUE</code></p>
  
  <p>How do I do this ?</p>
  
  <p>Tried <code>v [ isGoodNumber(v) == TRUE ]</code> but it doesn't work :-)</p>
  
  <p>Thanks !! </p>