[R] Extracting unique entries by a column

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Tue Apr 14 23:26:04 CEST 2015


In the same way they would be different in any programming language. See R FAQ 7.31.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

On April 14, 2015 12:39:50 PM PDT, Vikram Chhatre <crypticlineage at gmail.com> wrote:
>I have a data frame of dim 3x600.  There are pairs of rows which have
>the
>exact same value in column 3.
>
>head(df)
>                POP1         POP2   ABSDIFF
>L0005.01 0.98484848 0.688118812 0.2967297
>L0005.03 0.01515152 0.311881188 0.2967297
>L0008.02 0.97727273 0.004424779 0.9728479
>L0008.04 0.02272727 0.995575221 0.9728479
>L0012.03 0.98684211 0.004385965 0.9824561
>L0012.01 0.01315789 0.995614035 0.9824561
>
>I want to unique sort on df$ABSDIFF so that only one row per pair
>remains
>in the subset.
>
>>df_subset <- df[df(!duplicated(df$ABSDIFF), ]
>
>This does not work. So I literally checked:
>
>>identical(df[1,3], df[2,3])
>FALSE
>
>How is 0.2967297 different from 0.2967297?  I am puzzled.
>
>Thanks for any insight.
>
>Vikram
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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