title: How can I get a count of unique values grouped by another column value
body: <p>I am wanting to create a count of unique values per id number</p>
  <p>For example given the data</p>
  <pre><code>test &lt;- data.frame(&quot;id&quot; = c(1,1,2,3,3,3), &quot;product&quot; = c(&quot;clothes&quot;,&quot;clothes&quot;,&quot;home&quot;,&quot;home&quot;,&quot;outdoors&quot;,&quot;outdoors&quot;))
  </code></pre>
  <p>I want the output</p>
  <pre><code>id     unique_product_count
  1       1
  2       1
  3       2
  </code></pre>
  <p>I've tried variations such as</p>
  <pre><code>test %&gt;% group_by(id) %&gt;% distinct(product)
  # A tibble: 4 × 2
  # Groups:   id [3]
       id product 
    &lt;dbl&gt; &lt;chr&gt;   
  1     1 clothes 
  2     2 home    
  3     3 home    
  4     3 outdoors
  </code></pre>
  <p>But haven't gotten any to work.</p>