title: How to check if several dates lie within a interval using data.table and lubridate?
body: <p>I have a data.table with several columns with dates,
  and two columns defining an interval.
  I want to check if any of the dates lies within that interval.</p>
  <p>Here it is a toy example with just three column dates.</p>
  <pre><code>DT &lt;- data.table(d1=dmy(c(&quot;1-1-2019&quot;, &quot;2-2-2019&quot;)), 
      d2=dmy(c(&quot;1-3-2019&quot;, &quot;2-2-2022&quot;)), 
      d3=dmy(c(&quot;1-1-2020&quot;, &quot;2-2-2021&quot;)),
      initial=dmy(c(&quot;1-1-2020&quot;,&quot;5-5-2022&quot;)), 
      final=dmy(c(&quot;1-3-2020&quot;,&quot;1-1-2023&quot;)))
  
           d1         d2         d3    initial      final
   2019-01-01 2019-03-01 2020-01-01 2020-01-01 2020-03-01
   2019-02-02 2022-02-02 2021-02-02 2022-05-05 2023-01-01
  </code></pre>
  <p>I can do it like this: (it can also be used to filter instead of creating a new column)</p>
  <pre><code>DT[,new:=(d1 &gt;= initial &amp; d1 &lt;= final) | (d2 &gt;= initial &amp; d2 &lt;= final) | 
     (d3 &gt;= initial &amp; d3 &lt;= final)]
  </code></pre>
  <p>But this is quite long, specially if I had more than three columns.</p>
  <p>I have tried this compact version</p>
  <pre><code>DT[,any( c(d1,d2,d3 ) %within% interval(initial, final))]
  </code></pre>
  <p>But it doesn't seem to work.</p>
  <p>What is the simplest way I can do it?<br />
  Any solution with other packages are also welcome</p>