title: R: A for loop in R to check if values are greater than equation
body: <p>For some reason I cannot think through how I should return only the values that match a given if statement. I would like only the values in a matrix that are greater than a specific value.</p>
  
  <pre><code> somefunction &lt;- function(c,r,matrix){
   d &lt;- sqrt((matrix-center[1])^2 + (matrix-center[2])^2)
        for (i in matrix) {
      if (d &lt; r)
                 ##only return these values less than r
  </code></pre>
  
  <p>any guidance will help, even a direction to another post.   </p>