title: Add a flag that meet certain conditions in a data frame
body: <p>For each subject, if either Cmax or AUC is zero, then FLAG should be 0. If both are 1 then FLAG=1.</p>
  
  <pre><code>SUB    METRIC    BE    FLAG
   1      Cmax     0       NA
   1      AUC      1       NA
   2      Cmax     1       NA
   2      AUC      1       NA
   3      Cmax     1       NA
   3      AUC      1       NA
   4      Cmax     1       NA
   4      AUC      0       NA
  </code></pre>
  
  <p>output should be this:</p>
  
  <pre><code>SUB    METRIC    BE     FLAG
   1      Cmax     0       0
   1      AUC      1       0
   2      Cmax     1       1
   2      AUC      1       1
   3      Cmax     1       1
   3      AUC      1       1
   4      Cmax     1       0
   4      AUC      0       0
  </code></pre>
  
  <p>Then I want to take the sum of FLAG but FLAG=1 for unique subject should be added once because it is the same subject. so, the sum for FLAG in the above should be equal to 2 not 4. I am using RStudio.</p>