title: add the number of specific rows to a summarise() call
body: <p>I've tried the following reproducible data and code to get my <code>Current_output</code>:</p>
  <pre><code>&quot;study n_effect
       3        2
       5        2
       8        2&quot;
  </code></pre>
  <p>However, I wonder how to extend my code to get my <code>Desired_output</code>?:</p>
  <pre><code>&quot;study n_effect  composite  subscale
       3        2      1      1        # Add the number of rows for reporting
       5        2      1      1        # That are composite and subscale
       8        2      1      1&quot;
  </code></pre>
  <pre><code>library(tidyverse)
  
  m=&quot;
  study subscale  reporting  obs include yi   vi         study_type
  1        A      subscale   1   yes     1.94 0.33503768 standard
  1        A      subscale   2   yes     1.06 0.01076604 standard
  2        A      subscale   3   yes     2.41 0.23767389 standard
  2        A      subscale   4   yes     2.34 0.37539841 standard
  3        A&amp;C    composite  5   yes     3.09 0.31349510 standard
  3        A&amp;C     subscale  6   yes     3.99 0.01349510 standard
  4        A&amp;B    composite  7   yes     2.90 0.91349510 standard
  4        A&amp;B    composite  8   yes     3.01 0.99349510 standard
  5        G&amp;H     subscale  9   yes     1.01 0.99910197 alternative
  5        G&amp;H    composite  10  yes     2.10 0.97910095 alternative
  6        E&amp;G    composite  11  yes     0.11 0.27912095 alternative
  6        E&amp;G    composite  12  yes     3.12 0.87910095 alternative
  7        E      subscale   13  yes     0.08 0.21670360 alternative
  7        G      subscale   14  yes     1.00 0.91597190 alternative
  8        F      subscale   15  yes     1.08 0.81670360 alternative
  8        E      composite  16  yes     0.99 0.91297170 alternative&quot;
  data &lt;- read.table(text=m,h=T)
  
  data %&gt;% 
    group_by(study) %&gt;% 
    filter(all(c(&quot;composite&quot;,&quot;subscale&quot;) %in% reporting)) %&gt;%
    summarise(study = study, n_effect = n()) %&gt;% distinct()
  
  
  Current_output =
  &quot;study n_effect
       3        2
       5        2
       8        2&quot;
  
  Desired_output =
  &quot;study n_effect  composite  subscale
       3        2      1      1
       5        2      1      1
       8        2      1      1&quot;
  </code></pre>