title: Using historical High/Low Tide data from NOAA to classify my data points as high or low based on date and time
body: <p>I'm pretty new to R and I'm working on adding tide data to an animal movement data frame. My animal data includes a date_time column with multiple data points occurring in each day. The tide data also has multiple points per day, as tide typically changes between high and low 4 times per day. For this reason, I haven't tried to use a loop.
  I'd like to create a new column in R that will classify each date/time into a &quot;LOW&quot; or &quot;HIGH&quot; category based on historical data from NOAA. So far, I've followed this: <a href="https://stackoverflow.com/questions/41334634/classify-date-time-by-tidal-states/66606062?noredirect=1#comment117743924_66606062">Classify date/time by tidal states</a></p>
  <p>After organizing my data frames into tide2015 and rays2015, when I get to the last line of code:</p>
  <p><code>Tidal.State15=tide2015$High.Low[pmax(findInterval(rays2015$Date - 3600*3, tide2015$datetime), findInterval(rays2015$Date + 3600*3, tide2015$datetime))]</code></p>
  <p>I get the same error as the original post:
  <code>Error in `$&lt;-.data.frame`(`*tmp*`, Tidal.State, value = c(&quot;L&quot;, &quot;H&quot;, &quot;L&quot;,  :  replacement has 38 rows, data has 39</code></p>
  <p>I'm not sure how to get around this error. I know there are no duplicates in my data, all my dates and times are in POSIXct format, and all dates in my data are accounted for in the NOAA tide data.
  Any suggestions would be greatly appreciated!</p>