title: Implementation of Incremental counter in R without using for loop
body: <p>I have a data frame with 2 variables populated with approx.100K values.
  I need to implement an <code>incremental counter</code> as the third column in the dataframe.<br>
  Below is data frame,  </p>
  
  <pre><code>    **A**               **B**       
      1                     2          
      4                     3                   
      3                     2                   
      2                     0                   
      1                     0                   
      2                     0                   
      3                     2                   
      1                     2                   
      3                     2                     
      2                     0                   
      2                     0                   
      3                     0                   
      4                     0                      
      2                     0                   
      9                     1                  
  </code></pre>
  
  <p>Also, There are certain condition to be satisfied before implementing the counter as follows,<br>
  a. Counter should be incremented only when <code>A&gt;=1</code> and <code>B=0</code>.<br>
  b. The <strong>first 2 datapoints</strong> where the condition <code>A&gt;=1</code> and <code>B=0</code> satisfies should not increment the <code>counter</code>.</p>
  
  <p>My expected output is as follows.  </p>
  
  <pre><code>    **A**               **B**      **Incremental Counter  
      1                     2                 0    
      4                     3                 0  
      3                     2                 0  
      2                     0                 0  
      1                     0                 0  
      2                     0                 1  
      3                     2                 0  
      1                     2                 0  
      3                     2                 0    
      2                     0                 0  
      2                     0                 0  
      3                     0                 2  
      4                     0                 3     
      2                     0                 4  
      9                     1                 0   
  </code></pre>
  
  <p>Thanks,</p>