With a dataframe like this one:
ID Year Temp ph 1 P1 1996 11.3 6.80 2 P1 1996 9.7 6.90 3 P1 1997 9.8
You can include your which.max call as the first argument to your subsetting call:
which.max
df[which.max(df$Temp),]