# example data
DT <- data.table(Titanic)
Suppose that, for each sex, we want the rows with the highest survival numbers:
DT[Survived == "Yes", .SD[ N == max(N) ], by=Sex]
# Class Sex Age Survived N
# 1: Crew Male Adult Yes 192
# 2: 1st Female Adult Yes...