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 base solution
group_sorted <- group[order(group$Subject, -group$pt),] group_sorted[!duplicated(group_sorted$Subject),] # Subject pt Event # 1 5 2 # 2 17 2 # 3 5 2
Order the data frame by pt (descending) and then remove rows duplicated in Subject
pt
Subject