Count of unique values in a rolling date range for R
This question already has an answer for SQL , and I was able to implement that solution in R using sqldf . However, I've been unable to find a way to implement it using data.table . The problem is to count the distinct values of one column within a rolling date range, e.g. (and quoting directly from the linked question) if the data looked like this: Date | email -------+---------------- 1/1/12 | test@test.com 1/1/12 | test1@test.com 1/1/12 | test2@test.com 1/2/12 | test1@test.com 1/2/12 | test2@test.com 1/3/12 | test@test.com 1/4/12 | test@test.com 1/5/12 | test@test.com 1/5/12 | test@test.com