title: Which function seems to be matching on multiple values in data frames
body: <p>I'm trying to write an R script that indicates what hours/minutes in the day &quot;fall into&quot; a specific start/end time.</p>
  <p>So, for example a class with a start/end time of 8 - 8:30 am, would &quot;fall into&quot; 8:00, 8:05, 8:10...8:30. And would not fall into other times.</p>
  <p>The end goal would be a data frame with the first column as the start time, the second column, the end time, and the third column the individual time that &quot;falls into&quot; the start/end times. E.g.:</p>
  <p>start    end    time
  8:00     8:30   8:00
  8:00     8:30   8:05
  8:00     8:30   8:10</p>
  <p>Here's my current script:</p>
  <pre><code>library(&quot;tidyverse&quot;)
  
  #create initial matrix
  vector1 &lt;- c(1:24) #listing of hours
  vector2 &lt;- seq.int(.05,.60,.05) #listing of every 5 minutes
  possible_hrs &lt;- data.frame(outer(vector1,vector2,'+')) 
  #matrix of all possible hours/minutes
  
  #pull in start/end time possibilities
  start &lt;-c(5,5.30)
  end &lt;-c(8,9.55)
  class_time&lt;-data.frame(start,end)
  
  
  times&lt;-function(class_time,possible_hrs){
  
  #extract the values that match; where possible hours &quot;fall into&quot; start/end times
  match = which(possible_hrs &gt;= class_time$start &amp; possible_hrs &lt;= class_time$end, arr.ind=TRUE) 
  
  values = data.frame(sort(possible_hrs[match]))
  
  starts &lt;- class_time$start
  ends &lt;- class_time$end
  times &lt;- values
  
  results&lt;-data.frame(starts,ends,times)
  }
  
    results2 &lt;- times(class_time,possible_hrs)
    results2
  </code></pre>
  <p>But something is going wrong with the which() function as I'm getting values that shouldn't &quot;fall in&quot; the start/end times respectively.</p>
  <p>So the time 8:05 shouldn't fall into 5:00 - 8:00 time block. And likewise I'm not getting all of the results in the second time block...I'm not getting a time of 9:00 that should fall into the 8:00 - 9:55 time block.</p>