title: How to subset a table from another table by matching Lat and Long
body: <p>I have a large table of swell period associated with a lat, long, and date/time. Lat, long, and date are separate columns. I have a smaller table of exact locations, lat and longs in seperate column, in which I want to extract swell period per date/time stamp. I am stumped on how to do this. I have provided samples of my code and tables below. My attempt seems to only pull out 6 of the 20 locations. I am confident there is matching lat and longs.</p>
  <p><img src="https://i.stack.imgur.com/AtUwR.png" alt="full spatial DT" /></p>
  <p><img src="https://i.stack.imgur.com/Ix0S8.png" alt="specific locations" /></p>
  <pre><code>
  x &lt;- as.vector(round(c(-121.110423, -120.562848, -120.057825,  -119.717691, -119.439510, -119.041160, -118.586216, 
                             -118.507400, -118.087338, -117.662998, -117.437052, -117.335509, -118.160157, -119.059945, 
                             -119.943535, -120.515873, -119.070552, -118.295248, -119.471023, -120.584913), 2))
  
  y &lt;-  as.vector(round(c(34.560459, 34.253113,34.348268, 34.147373, 34.256965, 33.989257, 33.913609, 33.699766, 33.576926, 
                             33.272809, 32.922927, 32.535688, 32.606003, 32.500511, 32.644805, 33.138259, 33.135506, 33.102819,
                             33.696946, 33.703024), 2))
  
  ta_loc &lt;- as.data.frame(cbind(x, y))
  
  
  Ta_data &lt;- as.data.frame(rasterToPoints(final_ras_ta)) %&gt;%
    pivot_longer(!c(x,y), names_to = &quot;date&quot;, values_to = &quot;period&quot;) %&gt;%
    mutate(date = gsub(&quot;X&quot;, &quot;&quot;, date),
           date = as.numeric(date),
           date = as_datetime(date),
           x = round(x, 2),
           y = round(y , 2)) %&gt;% 
    filter(x %in% ta_loc$x,
           y %in% ta_loc$y )
    
  a &lt;- Ta_data %&gt;% 
    st_as_sf(. , coords = c(&quot;x&quot;, &quot;y&quot;), crs = 4326)
  
  b &lt;- ta_loc %&gt;% 
    st_as_sf(. , coords = c(&quot;x&quot;, &quot;y&quot;), crs = 4326)
  
  loc &lt;- a %&gt;% 
    group_by(date) %&gt;% 
    filter(geometry == b$geometry)
    
  </code></pre>