title: Create new variable of counts of observation using dplyr
body: <p>How can I create a new column that represents the count of another column in my dataframe using dplyr?</p>
  <p>For example:</p>
  <pre><code>library(dplyr)
  
  d &lt;- tibble(x = c(&quot;a&quot;, &quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;c&quot;, &quot;c&quot;))
  </code></pre>
  <pre><code># A tibble: 6 x 1
    x    
    &lt;chr&gt;
  1 a    
  2 a    
  3 b    
  4 c    
  5 c    
  6 c 
  </code></pre>
  <p>I understand I can do this with a join, but can I do it without a join?</p>
  <pre><code>d %&gt;%
    left_join(count(d, x), by = &quot;x&quot;)
  </code></pre>
  <pre><code># A tibble: 6 x 2
    x         n
    &lt;chr&gt; &lt;int&gt;
  1 a         2
  2 a         2
  3 b         1
  4 c         3
  5 c         3
  6 c         3
  </code></pre>