2 Answers
2

As @Mittenchops said, you're looking for the Cartesian product. There's a function for this, CJ. You can get the combos you want with unique(CJ(time,bucket)). To use this with your data.table, you can (i) set the key and (ii) join it with the CJ:

By the way, when you "join" using x[y,...] syntax (where x and y are both data.tables), there is a hidden by...a by-without-by... on (possibly only the first part of) x's key. Look up "by-without-by" in the documentation or on google for details.

It sounds like the thing that makes your question difficult is less about aggregating, and more about creating the cartesian product of times by groups to fill in the gaps left by the aggregate. It would be great if there were a flag in the function to accomplish this, but there doesn't seem to be.

So, this isn't elegant, but here's one solution that accomplishes that, by constructing that structure, then grafting the results of aggregation onto that scaffolding: