title: conditional Substacting numbers
body: <p>I have data frame like this</p>
  
  <pre><code>test &lt;- data.frame(gr=rep(letters[1:2],each=6),No=c(100:105,200:205))
  
     gr  No
  1   a 100
  2   a 101
  3   a 102
  4   a 103
  5   a 104
  6   a 105
  7   b 200
  8   b 201
  9   b 202
  10  b 203
  11  b 204
  12  b 205
  </code></pre>
  
  <p>in the <code>No</code> column the numbers are increasing in each <code>gr</code>. I need to sum <code>gr a</code> with 100 and <code>b</code> with 50 and need to have consecutive decrease after this operation. </p>
  
  <p>I would like to have a new column that consecutive decrease with this increase. So I tried</p>
  
  <pre><code>decrese_func &lt;- function(No,gr){
  
     if(any(gr=="a")){
       No+100
  
     }
     else
      No+50 
   }
  
     test%&gt;%
     group_by(gr)%&gt;%
     mutate(new_column=decrese_func(No,gr))
  
  # A tibble: 12 x 3
  # Groups:   gr [2]
     gr       No new_column
     &lt;fct&gt; &lt;int&gt;      &lt;dbl&gt;
   1 a       100        200
   2 a       101        201
   3 a       102        202
   4 a       103        203
   5 a       104        204
   6 a       105        205
   7 b       200        250
   8 b       201        251
   9 b       202        252
  10 b       203        253
  11 b       204        254
  12 b       205        255
  </code></pre>
  
  <p>but what I need is like this </p>
  
  <pre><code> gr       No new_column
     &lt;fct&gt; &lt;int&gt;      &lt;dbl&gt;
   1 a       100        200
   2 a       101        199
   3 a       102        198
   4 a       103        197
   5 a       104        196
   6 a       105        195
   7 b       200        250
   8 b       201        249
   9 b       202        248
  10 b       203        247
  11 b       204        246
  12 b       205        245
  </code></pre>
  
  <p>I cannot figure it out how to have consecutive decrease ?</p>
  
  <p>Thx.</p>