Re: [R] duplicate values

2008-11-16 Thread Prof Brian Ripley
Is the question 'duplicated next to each other' or 'duplicated anywhere later'? I read it as the latter, so would use dup <- duplicated(x$dt) or dup <- duplicated(x[c("Date", "time")] Also, be very careful as Date-time values like this can be duplicated and refer to different times on days

Re: [R] duplicate values

2008-11-16 Thread Gabor Grothendieck
Here are three possibilities: # 1 DF[!duplicated(DF$Datetime), ] # 2 aggregate(DF[-1], DF[1], head, 1) These give the first one but if you want the last one use the fromLast= arg of duplicated or tail instead of head with aggregate. # 3 # The zoo package can read in data, convert the # first co

Re: [R] duplicate values

2008-11-16 Thread Erik Iverson
Oliver Bandel wrote: Antje Nöthlich web.de> writes: [...] Now for the whole dataframe i would like to delete rows that have the same "Datetime" value as the prior row. Well, if you do this, then you loose data. is this really, what you want? Throwing away data? I would think it make sense,

Re: [R] duplicate values

2008-11-16 Thread Erik Iverson
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

Re: [R] duplicate values

2008-11-16 Thread jim holtman
This should do it for you: > x <- read.table(textConnection( "Date time > Temperature + 12008-6-1 00:00:00 5 + 22008-6-1 02:00:00 5 + 32008-6-1 03:00:00 6 + 42008-6-1 03:00:00 0 + 52008-6-1 04:00:00 6 +

Re: [R] duplicate values

2008-11-16 Thread Oliver Bandel
Antje Nöthlich web.de> writes: [...] > Now for the whole dataframe i would like to delete rows that have the same > "Datetime" value as the prior row. Well, if you do this, then you loose data. is this really, what you want? Throwing away data? I would think it make sense, if all columns are eq

[R] duplicate values

2008-11-16 Thread Antje Nöthlich
Hei R Users, i have the following dataframe: Datetime Temperature and many more collumns 12008-6-1 00:00:00 5 22008-6-1 02:00:00 5 32008-6-1 03:00:00 6 42008-6-1 03:00:00 0 52008-6-1 04:00:00