title: Identifying entries that have any overlap with reference times using dplyr R
body: <p>I have a set of audio clips from different sites and files that I have manually extracted and a set that have been extracted automatically. I want to identify any clips in the automatically extracted set at the same site and file that overlap at all with those in the manually extracted set.</p>
  <p>For example:</p>
  <pre><code>library(dplyr)
  set.seed(123)
  group &lt;- as.factor(round(runif(100, 1, 10),0))
  file &lt;- sample(LETTERS, 100, TRUE)
  start &lt;- round(runif(100, 0, 100), 2)
  end &lt;- round(start + (runif(100, 0, 1)), 2)
  
  auto &lt;- bind_cols(group, file, start, end) %&gt;% 
          set_names(., nm = c(&quot;group&quot;, &quot;file&quot;, &quot;start&quot;, &quot;end&quot;))
  
  man &lt;- bind_rows(sample_n(auto, 10) %&gt;% 
         mutate(start = round(start - runif(10, 0, 1), 2), 
                end = round(end - runif(10,0, 0.5), 2)), 
                   sample_n(auto, 10) %&gt;% 
         mutate(start = round(start + runif(10, 0, 1), 2), 
                end = round(start + runif(10,0, 0.5), 2)))
  </code></pre>
  <p>I have been trying to use <code>dplyr::between</code> like this:</p>
  <pre><code>res &lt;- auto %&gt;% 
    left_join(., man, by = c(&quot;group&quot;, &quot;file&quot;)) %&gt;%  
    drop_na() %&gt;% 
    mutate(pos = (between(start.x, start.y, end.y) | between(end.x, start.y, end.y)))
  </code></pre>
  <p>But it is just returning <code>FALSE</code>. The code doesn't throw an error so I am guessing there is in issue in the way I have written it.</p>
  <p>If you split out the or in the last <code>mutate</code> to check if either <code>between</code> function is the issue, like this:</p>
  <pre><code>res &lt;- auto %&gt;% 
    left_join(., man, by = c(&quot;group&quot;, &quot;file&quot;)) %&gt;%  
    drop_na() %&gt;% 
    mutate(x = between(start.x, start.y, end.y),
           y = between(end.x, start.y, end.y),
           pos = x | y  == &quot;TRUE&quot;)
  </code></pre>
  <p>you can see that both return <code>FALSE</code>.</p>
  <p>It seems like it should be a relatively simple thing, but I am struggling to figure it out.</p>