title: How do I get unique element from a vector, keeping its name?
body: <p>I know there is the function <code>unique()</code> that extracts the unique values from a vector. But I lose its name.</p>
  
  <p>Ex.</p>
  
  <pre><code>vector = c("A" = 1, "B" = 2, "A" = 1, "C" = 3, "B" = 2, "D" = 3, "D" = 3)
  </code></pre>
  
  <p>If I print I should see:</p>
  
  <pre><code>A B A C B D D
  1 2 1 3 2 3 3
  </code></pre>
  
  <p><strong>Expected output</strong>:</p>
  
  <pre><code>A B C D
  1 2 3 3
  </code></pre>
  
  <hr>
  
  <p>Attempts:</p>
  
  <p>If I use: <code>unique(vector)</code> I only get <code>1 2 3</code></p>
  
  <p>If I use: <code>vector[!duplicated(vector)]</code> I get:</p>
  
  <pre><code>A B C 
  1 2 3 
  </code></pre>
  
  <p>This is close, but the <code>"D" = 3</code> is missing.</p>