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:
Here's another data.table solution, since which.max does not work on characters
data.table
which.max
library(data.table) group <- data.table(Subject=ID, pt=Value, Event=Event) group[, .SD[order(pt, decreasing = TRUE) == 1], by = Subject]