[R] Selecting unique values
Daniel Malter
daniel at umd.edu
Tue Jul 26 09:59:02 CEST 2011
Steven's solution is great, but it will only work if the rows are really
duplicates. If the data frame contains another variable whose values vary,
it will not work because then the rows are obviously unique.
df<-data.frame(df,value=rnorm(11))
unique(df)
You would then have to make a decision, which row to select for each species
at the same longitude and latitude, e.g., by first index number or min/max
"value," etc. This would become slightly more complicated. Let us know if
Steven's solution is what you were looking for.
Kumar Mainali wrote:
>
> Greetings
>
> I have a dataset with occurrence records of multiple species. I need to
> get
> rid of multiple listings of the same occurrence point for a species (as
> you
> see below in red and blue typeface). How do I create a dataset only with
> unique set of longitude and latitude for each species? Thanks in advance.
>
> Species_name Longitude Latitude
> Abies concolor -106.601 35.868
> Abies concolor -106.493 35.9682
> Abies concolor -106.489 35.892
> Abies concolor -106.496 35.8542
> Accipiter cooperi -119.688 34.4339
> Accipiter cooperi -119.792 34.5069
> Accipiter cooperi -118.797 34.2581
> Accipiter cooperi -77.38333 39.68333
> Accipiter cooperi -77.38333 39.68333
> Accipiter cooperi -75.99153 40.633335
> Accipiter cooperi -75.99153 40.633335
>
> - Kumar
>
> --
> Section of Integrative Biology
> University of Texas at Austin
> Austin, Texas 78712, USA
>
> [[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.
>
--
View this message in context: http://r.789695.n4.nabble.com/Selecting-unique-values-tp3694856p3695083.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list