title: Checking that the conditions are correct accordingly
body: <p>I would like to know if the code below is properly written for generating <code>group_cols</code>. Making a brief explanation of the code I made:</p>
  <p>My first <code>if()</code> is if I have any row where <code>PV$DTT == DTest &amp; PV$Week== Wk</code>. The <code>else if</code> is when I have <code>PV$Week == Wk</code> and <code>PV$Category==CategoryChosse</code>, but not <code>PV$DTT == DTest</code>. That's why I inserted the sign <code>!</code>. The last condition means if I don't have any of the conditions reported above. Is the code correct according to my thinking?</p>
  <pre><code>PV &lt;- structure(list(date2 = c(&quot;2021-06-23&quot;, &quot;2021-06-24&quot;), Week = c(&quot;Wednesday&quot;, 
   &quot;Thursday&quot;), Category = c(&quot;ABC&quot;, &quot;FDE&quot;), DTT = c(&quot;Hol&quot;, &quot;Hol&quot;), DR1 = c(4, 1), 
  DR01_PV = c(0, 0), DR02_PV = c(0, -1), DR03_PV = c(-5,-4), DR04_PV = c(-1, -3), 
  DR05_PV = c(-1, -3)), class = &quot;data.frame&quot;, row.names = 1:2)
  
      &gt; PV
             date2      Week Category DTT DR1 DR01_PV DR02_PV DR03_PV DR04_PV DR05_PV
      1 2021-06-23 Wednesday      ABC Hol   4       0       0      -5      -1      -1
      2 2021-06-24  Thursday      FDE Hol   1       0      -1      -4      -3      -3
  
  group_cols &lt;-
    if (any(PV$DTT == DTest &amp; PV$Week == Wk, na.rm = TRUE)) {
      c(&quot;Category&quot;, &quot;Week&quot;, &quot;DTT&quot;)
    } else if (any(PV$Week == Wk &amp; PV$Category == CategoryChosse &amp; !PV$DTT == DTest, na.rm=TRUE)) {
      c(&quot;Category&quot;, &quot;Week&quot;)
    } else {
      &quot;Week&quot;
    }
  </code></pre>
  <p><strong>Running some tests:</strong></p>
  <pre><code>1)
  CategoryChosse&lt;-&quot;FDE&quot;
  DTest&lt;-&quot;0&quot;
  Wk&lt;-&quot;Thursday&quot;
  
  &gt; group_cols
  [1] &quot;Category&quot; &quot;Week&quot;
  
  2)
  CategoryChosse&lt;-&quot;FDE&quot;
  DTest&lt;-&quot;Hol&quot;
  Wk&lt;-&quot;Thursday&quot;
  
  [1] &quot;Category&quot; &quot;Week&quot; &quot;DTT&quot;
  
  3)
  CategoryChosse&lt;-&quot;FDE&quot;
  DTest&lt;-&quot;Hol&quot;
  Wk&lt;-&quot;Friday&quot;
  
  &gt; group_cols
  [1] &quot;Week&quot;
  </code></pre>