Re: [R] duplicate values

From: Erik Iverson <iverson_at_biostat.wisc.edu>
Date: Sun, 16 Nov 2008 12:24:02 -0600

Antje -

I may be missing something, but I usually do this with the negation of duplicated instead of unique.

So, as an example:

test <- data.frame(a = rep(1:5, each = 2),

    b = rep(1:5, each = 2), c = rnorm(10))

test[!duplicated(test[c("a", "b")]), ]

Hope that helps!

Erik

Antje Nöthlich wrote:
> Hei R Users,
>
> i have the following dataframe:
>
> Datetime Temperature and many more collumns
> 1 2008-6-1 00:00:00 5
> 2 2008-6-1 02:00:00 5
> 3 2008-6-1 03:00:00 6
> 4 2008-6-1 03:00:00 0
> 5 2008-6-1 04:00:00 6
> 6 2008-6-1 04:00:00 0
> 7 2008-6-1 05:00:00 7
> 8 2008-6-1 06:00:00 7
> . . .
> . . .
> . . .
> 3000 2008-8-31 00:00:00 3
>
>
> the problem is that row 3 & 4 and row 5 & 6 have the same "Datetime" value but they differ in the values of the "Temperature" column.
> Now for the whole dataframe i would like to delete rows that have the same "Datetime" value as the prior row.
> I have tried unique(dataframe), but it does not work here because the rows are no real duplicates of each other.
> thanks in advance for your help!
>
> Antje
>
> ______________________________________________
> 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.



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. Received on Sun 16 Nov 2008 - 18:27:31 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 16 Nov 2008 - 19:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive