In a dataset with multiple observations for each subject I want to take a subset with only the maximum data value for each record. For example, with a following dataset:
Another data.table solution:
data.table
library(data.table) setDT(group)[, head(.SD[order(-pt)], 1), by = .(Subject)]