title: Rounding a column of values to the nearest values in another column (R Code)
body: <p>I have a data frame of coordinates like the one bellow.</p>
  
  <pre><code>longitude latitude
  1    95.93604 41.25908
  2    95.93371 41.25941
  3    95.93137 41.25974
  4    95.92904 41.26008
  5    95.92670 41.26041
  </code></pre>
  
  <p>and I want to round both the longitudes and latitudes to the nearest values in a existing data frame with  coordinates like the one below.</p>
  
  <pre><code>latitude longitude
  41.45131  96.42024
  40.81344  96.66093
  41.11293 102.85215
  40.37834  96.61095
  42.84468  97.40045
  41.18000  96.11592
  40.69164  99.53231
  40.37834  96.61095
  41.34500  95.95712
  </code></pre>
  
  <p>How can I do this in R? I tried using the interp1 function from the package pracma, but I was not able to get the correct result. I suppose I could write a function of my own, but I am also curious if there is a simpler and more elegant way of going about this. If you have any other suggestions for how I can find the closest corresponding coordinates from one data frame to the other, that would be appreciated too! Thank you! </p>