Using the answer in here, I have successfully calculated minima and maxima by group many times. This time it doesn't work and I don't understand why. Here is a reproducible example.
example <- structure(
list(ID = 1:10,
date =
c("2005-05-09", "2006-09-18", "1996-06-14", "1997-01-06",
"1997-03-13", "1997-05-06", "1990-01-04", "1990-01-11",
"1989-12-28", "1989-12-28"),
name = c("a", "a", "a", "a", "a", "a", "b", "b", "b", "b")),
.Names = c("ID", "date", "name"),
class = c("data.table", "data.frame"),
row.names = c(NA, -10L))
example[example[, .I[which.min(date)], by=c("name")]$V1]
I was expecting something like:
1996-06-14 a
1989-12-28 b
but instead I get an empty data table. Why?