Here is an example of my data set;
Date Time(GMT)Depth Temp Salinity Density Phosphate 24/06/2002 1000 1 33.855 0.01 24/06/2002
# First find the maxvalues maxvals = aggregate(df$Depth~df$Date, FUN=max) #Now use apply to find the matching rows and separate them out out = df[apply(maxvals,1,FUN=function(x) which(paste(df$Date,df$Depth) == paste(x[1],x[2]))),]
Does that work for you?