Skip to content
Prev 327658 / 398502 Next

selection based on dates

On Jul 30, 2013, at 7:13 AM, Andras Farkas wrote:

            
Hi,

It is not clear to me that the result you show in z is what you describe in words.  On the other hand, I think the following will "eliminate the rows with the earliest date per ID number".

x <- structure(c("1/1/13", "1/5/13", "1/9/13", "2/1/13", "2/5/13", 
"2/9/13", "15", "15", "15", "18", "18", "18", "20", "25", "28", 
"30", "35", "38"), .Dim = c(6L, 3L))

ix <- duplicated(x[,2])

z <- x[ix,]

Is that what you are looking to achieve?  By the way, the solution is not based upon selecting by date as your subject message suggests.  Do you need to filter on dates instead?  If that is so, then you will need a different solution.

Regards,
Ben
Ben Tupper
Bigelow Laboratory for Ocean Sciences
60 Bigelow Drive, P.O. Box 380
East Boothbay, Maine 04544
http://www.bigelow.org