title: How to count a occurrence in a dataframe in R, without repetition
body: <p>I have a question, I'm learning to use <code>group_by()</code> and <code>summarise()</code> in the R. But, I stopped at a question in the book I'm studying. </p>
  
  <p>Follow: "How many senators did each party have? Which one had more? Which ones had the least? Tip use: <code>group_by ()</code>, <code>summarize ()</code> and <code>n_distinct ()</code>"</p>
  
  <p>The data set seems like it's:</p>
  
  <p><a href="https://i.stack.imgur.com/N397B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/N397B.png" alt="enter image description here"></a></p>
  
  <p>I have tried to do like this:</p>
  
  <pre><code>    senators &lt;- senado %&gt;% group_by(Party) %&gt;% summarise(num_senators = n_distinct(senado$SenatorUpper))
  </code></pre>
  
  <p>But, I don't have success.</p>