Average and count with aggregation in R with dplyr
<p>I want to count the number of elements for the variable price equal to 0, 49 or if something else I also want the count but i don't care how many the price is in this case.
I want to do an average of price by terminal if this one is not equal to 0 or 49</p>

<pre><code>terminal &lt;- c("a", "b", "a", "c", "b", "b")
price &lt;- c(0, 49, 3.5, 0, 17, 32)
df &lt;- data.frame(terminal, price)

df %&gt;%
group_by(terminal, price) %&gt;%
summarise(count = n())
</code></pre>

<p>Here I want to have this count : 1, 1, 2, 1, 1 
and after this I'd like to get an average of the price of terminal when this one is not equal to zero or 49.</p>