title: Count number of distinct values in a vector
body: <p>I have a vector of scalar values of which I'm trying to get: "How many different values there are".</p>
  
  <p>For instance in <code>group &lt;- c(1,2,3,1,2,3,4,6)</code> unique values are <code>1,2,3,4,6</code> so I want to get <code>5</code>.</p>
  
  <p>I came up with:</p>
  
  <pre><code>length(unique(group))
  </code></pre>
  
  <p>But I'm not sure it's the most efficient way to do it. Isn't there a better way to do this?</p>
  
  <p><strong>Note:</strong> My case is more complex than the example, consisting of around 1000 numbers with at most 25 different values.</p>