[R] Unique command not deleting all duplicate rows

Erik Iverson eiverson at NMDP.ORG
Mon Aug 24 20:41:23 CEST 2009


I really don't think this is the issue.  I think the issue is that some columns of the data.frame, specifically V1, V2, and V4 should be checked versus R FAQ 7.31.  

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Don McKenzie
Sent: Monday, August 24, 2009 1:35 PM
To: Mehdi Khan
Cc: r-help at r-project.org
Subject: Re: [R] Unique command not deleting all duplicate rows

duplicated()

 > test.df
         V1     V2   V3      V4 V5   V6 V7
1 -115.380 32.894  195 162.940  D 8419  D
2 -115.432 32.864  115 208.910  D 8419  D
3 -115.447 32.773 1170 264.570  D 8419  D
4 -115.447 32.773 1170 264.570  D 8419  D
5 -115.447 32.773 1170 264.570  D 8419  D
6 -115.447 32.773 1170 264.570  D 8419  D
7 -115.447 32.773  149 186.210  D 8419  D
8 -115.466 32.855  114 205.630  D 8419  D
9 -115.473 32.800 1121 207.469  D 8419  D

 > test.df[!duplicated(test.df),]
         V1     V2   V3      V4 V5   V6 V7
1 -115.380 32.894  195 162.940  D 8419  D
2 -115.432 32.864  115 208.910  D 8419  D
3 -115.447 32.773 1170 264.570  D 8419  D
7 -115.447 32.773  149 186.210  D 8419  D
8 -115.466 32.855  114 205.630  D 8419  D
9 -115.473 32.800 1121 207.469  D 8419  D


On 24-Aug-09, at 11:23 AM, Mehdi Khan wrote:

> Hello everyone, when I run the "unique" command on my data frame,  
> it deletes
> the majority of duplicate rows, but not all of them.  Here is a  
> sample of my
> data. How do I get it to delete all the rows?
>
>  6 -115.38 32.894 195 162.94 D 8419 D
>
>  7 -115.432 32.864 115 208.91 D 8419 D
>
>  8 -115.447 32.773 1170 264.57 D 8419 D
>
>  9 -115.447 32.773 1170 264.57 D 8419 D
>
>  10 -115.447 32.773 1170 264.57 D 8419 D
>
>  11 -115.447 32.773 1170 264.57 D 8419 D
>
>  12 -115.447 32.773 149 186.21 D 8419 D
>
>  13 -115.466 32.855 114 205.63 D 8419 D
>
>  14 -115.473 32.8 1121 207.469 D 8419 D
>
>
> Thanks a bunch!
>
> Mehdi Khan
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting- 
> guide.html
> and provide commented, minimal, self-contained, reproducible code.

Don McKenzie, Research Ecologist
Pacific WIldland Fire Sciences Lab
US Forest Service

Affiliate Professor
School of Forest Resources, College of the Environment
CSES Climate Impacts Group
University of Washington

desk: 206-732-7824
cell: 206-321-5966
dmck at u.washington.edu
donaldmckenzie at fs.fed.us

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list