My data table looks something like this:
team player score
A 1 1
A 1 3
A 2 2
A 2 5
B 1 2
B 1 3
I want to return the rows with the min score for each team/player combo. e.g.,
A 1 1
A 2 2
B 1 2
I tried something like:
dt[, list(value=min(dt$score)), by=dt$team]
but that didn't work
Error in `[.data.frame`(dt, , list(value = min(dt$score)), : unused argument (by = dt$team)
and it wouldn't give me what I'm looking for anyway (only team mins). Similarly, I tried:
dt[which(dt$score == min(dt$score)), ]
but that gave the min across the whole list (just A 1 1)
Any suggestions?