What's the best way to get the tail row of a data.table by a factor?
Say I have:
> dt <- data.table(category = c("A", "A", "B", "B", "B"), value = c(1,2,3,4,5))
> dt
category value
1: A 1
2: A 2
3: B 3
4: B 4
5: B 5
I want to get this, but I'm not sure the most efficient way to do it:
category value
1: A 2
2: B 5
See Question&Answers more detail:os