There are so many posts on how to get the group-wise min or max with SQL. But how do you do it in R?
Let\'s say, you have got the following data frame
df is your data.frame -
df
library(data.table) setDT(df) # convert to data.table in place df[, value[which.min(t)], by = ID]
Output -
> df[, value[which.min(t)], by = ID] ID V1 1: a 3 2: b 2