title: Accessing grouped subset in dplyr
body: <p>I have the feeling this was already asked several times, but I can not make it run in my case. Don't know why.</p>
  
  <p>I <code>group_by</code> my data frame and calculate a <code>mean</code> from values. Additionally, I marked a specific row and I want to calculate the ratio of my fresh calculated <code>mean</code> with the value of my highlighted row of the subset.</p>
  
  <pre><code>library(dplyr)
  df &lt;- data.frame(int=c(5:1,4:1),
                   highlight=c(T,F,F,F,F,F,T,F,F),
                   exp=c('a','a','a','a','a','b','b','b','b'))
  
  df %&gt;%
    group_by(exp) %&gt;%
    summarise(mean=mean(int),
              l1=nrow(.),
              ratio_mean=.[.$highlight, 'int']/mean)
  </code></pre>
  
  <p>But for some reason, <code>.</code> is not the subset of <code>group_by</code> but the complete input. Am I missing something here?</p>
  
  <p>My expected output would be </p>
  
  <pre><code>exp    mean ratio_mean
    &lt;fct&gt; &lt;dbl&gt;      &lt;dbl&gt;
  1 a       3         1.67
  2 b       2.5       1.2
  </code></pre>