title: difference between !duplicated() and unique()
body: <p>I can't figure out what is the difference between these two functions in R.
  I have a data.frame, and I want to remove rows corresponding to duplicated values in a given column;</p>
  
  <pre><code>    Acc         Probe             Coord_homol
  1   NR_004442.1 225541_at~122     391
  2   NM_028059.2 241348_at~444     4642
  3   NM_028059.2 241348_at~468     4666
  4   NM_001114   212306_at~4357    5034
  5   NM_010573.2 230472_at~402     1987
  6   NM_029633.2 212306_at~4357    4289
  7   NM_00108196 212306_at~4357    4292
  8   NM_029891.2 205004_at~3421    2963
  9   NM_029891.2 205004_at~3635    3173
  10  NM_007892.2 221586_s_at~1356 1257
  11  NR_036613.1 208672_s_at~829  1301
  12  NR_036613.1 208673_s_at~1472 1854
  13  NM_011078.3 212726_at~3872    5175
  14  NM_011078.3 212726_at~3887    5190
  15  NM_013915.3 207164_s_at~1523 2911
  </code></pre>
  
  <p>in this case, I would like to remove rows 7 because the probe is the same as in row 6 (rows with same probes do not have to be successive ones).</p>
  
  <p>I first tried unique(), and later found duplicated.
  but if the following command </p>
  
  <pre><code>dat[!duplicated(dat$probe),]
  
  dat[unique(dat$probe),]
  </code></pre>
  
  <p>give the same number of lines in the resulting data.frame, the results are not the same.</p>
  
  <p>I tried on a much simpler case, like the following:</p>
  
  <p>a simple data.frame:</p>
  
  <pre><code>&gt; dat
     probe val
  1    aaa  10
  2    bbb  12
  3    ccc  45
  4    ddd  32
  5    aaa  42
  6    eee  10
  7    fff  13
  8    ccc  85
  9    aaa  75
  10   ddd  64
  </code></pre>
  
  <p>using !duplicated(): it seems to be what I want to do;</p>
  
  <pre><code>dat[!duplicated(dat$probe),]
  
    probe val
  1   aaa  10
  2   bbb  12
  3   ccc  45
  4   ddd  32
  6   eee  10
  7   fff  13
  </code></pre>
  
  <p>using unique():</p>
  
  <pre><code>dat[unique(dat$probe),]
  </code></pre>
  
  <p>I get: </p>
  
  <pre><code> probe val
  1   aaa  10
  2   bbb  12
  3   ccc  45
  4   ddd  32
  5   aaa  42
  6   eee  10
  </code></pre>
  
  <p>Not what I want; </p>
  
  <p>But what exactly unique() is doing ?</p>
  
  <p>Thanks for your help.</p>