title: dplyr- conditional and multiple filters grouped-by
body: <p>I want to filter based in more than conditions  in a generalizable way with a dplyr feel. My objective is is to filter to get the just the first month when a group got the goal of 40000. Given this data.</p>
  
  <pre><code>group month    output cumulouput  indi
  (fctr) (int)     (dbl)      (dbl) (dbl)
    A     1  9735.370    9735.37     0
    A     2 10468.063   20203.43     0
    A     3 11494.736   31698.17     0
    B     1 10186.465   10186.46     0
    B     2  9771.083   19957.55     0
    B     3  9871.636   29829.18     0
    B     4  9877.264   39706.45     0
    B     5  9009.198   48715.65     1
    B     6  9874.526   58590.17     1
    C     1 10613.868   10613.87     0
    C     2 10503.673   21117.54     0
    C     3 10397.098   31514.64     0
    C     4  9709.228   41223.87     1
    C     5  9861.669   51085.54     1
    C     6  9137.551   60223.09     1
  </code></pre>
  
  <p>For each group is to get the minimum month when group got the goal and the maximum month when group didn't reach the  goal. (???)</p>
  
  <p>This is the the result of the filter:</p>
  
  <pre><code>group   month    output cumulouput  indi
  (fctr) (int)     (dbl)      (dbl) (dbl)
    A     3 11494.736   31698.17     0
    B     5  9994.509  51800.365     1
    C     4  9709.228   41223.87     1
  </code></pre>
  
  <p>For the data:</p>
  
  <pre><code>library(dplyr)
  df1 &lt;- data.frame(group = rep(LETTERS[1:3], each=6),  month = rep(1:6,3))     %&gt;% 
  arrange(group,month) %&gt;% 
  mutate(output = rnorm(n=18,mean = 10000, sd = 722))%&gt;%
  group_by(group) %&gt;%
  mutate(cumulouput=cumsum(output))%&gt;% 
  filter(!(group=="A"&amp;month&gt;=4)) %&gt;% 
  mutate( indi= ifelse(cumulouput&gt;40000,1,0))
  </code></pre>