I know that we shouldn't subset .SD, but I would like to return the row from each group that corresponds to a max value in one of the columns. Here's how I'm doing it currently:<div><br></div><div>maxrows<- df.dt[, .SD[which(X1== max(X1)),], by = list(Var1, Var2, Var3)]</div>
<div><br></div><div>Is there a better way?</div><div><br></div><div>Thank you kindly,</div><div><br></div><div>Matthew</div><div><br></div><div><br></div>