title: Technique for Removing Duplicates Not Working (R)
body: <p>I tried a method to remove duplicates and I'd love to know why it doesn't work.</p>
  
  <p>Take this dataframe:</p>
  
  <pre><code>o&lt;-c(123,123,123,124,125,126)
  c&lt;-c(1,2,3,4,5,6)
  d&lt;-c(8,8,NA,8,8,8)
  df&lt;-data.frame(o,c,d)
  un&lt;-unique(df$o)
  df&lt;-df[un,]
  df
  </code></pre>
  
  <p>Now df is all NA's. Can someone tell me why????</p>
  
  <p><strong><em>Side note</em></strong> in my real dataset (private info, hence the sample df): this same code DIDN'T generate NA's for all values. I noticed a problem as something like the following would happen: <code>length(df$var)=100, length(unique(df$var))=90</code>. Fine. Then I would run that above code (re-writing the df), and I'd see: <code>length(df$var)=90, length(unique(df$var))=80</code>. If I kept looping, I'd eventually end up with one row of all NA's. </p>
  
  <p>I tried to replicate this error but the code that attempts to remove duplicates just generated all NA's, unlike in my real dataset. In any case, I'm hoping that discovering the problem in the code will answer my question.</p>
  
  <p>Thanks in advance for any help.</p>