How to select the row with the maximum value in each group

后端 未结 16 1930
北荒
北荒 2020-11-21 04:18

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:

16条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-21 05:09

    If you want the biggest pt value for a subject, you could simply use:

       pt_max = as.data.frame(aggregate(pt~Subject, group, max))
    

提交回复
热议问题