title: Count number of groups having a specific value over multiple variables
body: <p>I have a data frame such as:</p>
  
  <pre><code>city &lt;- c("a","a","b","b","c","c","c","c","d","e","e","f") 
  x &lt;- c(0,0,0,1,1,1,0,0,0,1,1,1)
  y &lt;- c(1,1,0,0,0,1,1,0,0,1,0,1)
  z &lt;- c(1,0,0,0,0,0,0,0,0,0,1,0)
  k &lt;- c(1,1,0,0,0,1,0,0,1,0,0,0)
  df &lt;- data.frame(city, x, y, z, k) 
  </code></pre>
  
  <p>where there is a grouping variable (e.g. city) and several dummy variables. I would like to count how many cities have each dummy variable = 1.</p>
  
  <p>What I managed so far is to count how many cities have a specific dummy = 1:</p>
  
  <pre><code>&gt; n_groups(filter(df, x == 1) %&gt;% 
  +            group_by(city))
  [1] 4
  </code></pre>
  
  <p>However, I would like to know whether it is possible to do that for all the dummies in my data frame so to obtain something like:</p>
  
  <pre><code>var count 
   x   4
   y   4
   z   2
   k   3
  </code></pre>
  
  <p>in which I have the number of cities having each dummy variables equal 1 (the count column) without having to do it individually for all the dummies in my sample.</p>
  
  <p>Thanks for your help!</p>