title: How to make a loop for distance R
body: <p>I have a data frame with locations for example like  this:</p>
  
  <pre><code>id       lat         lon
   a  51.50549  -0.0924609
   b  37.80248 -122.416634
   c  51.50609  -0.1238904
  </code></pre>
  
  <p>and so on.</p>
  
  <p>My goal is to make a loop so when one chooses location "a" there will be a subset which will include only locations in the radius of 500km from the "a" and exclude everything which is further than this. I think it should be a loop because there will be a constant change of a picked location so the final subset will be unique for each chosen location. </p>