hadley/tidyr — pull request #21 by Quiri (2014-08-18 11:53:27+00:00)
Title: expand functions added

Hello Hadley,

i'm a Data Analyst from Germany and love working with your packages, especially *dplyr*. While using the group_by %>% summarize chain, I discovered, that there are only groups made out of existing data. But if I want to group by date, for example, and I don't have data for a specific date, then its does not appear in the grouped result, so I have a "hole", but I would like to have

Date| n()
----|-------
2014-01-01| 5
2014-01-02| 0 *instead of no data at all*
2014-01-03| 7

and so on...

I didn't find a solution, so I build a function for it based on expand.grid(). I thought it would be a nice add to tidyr, so take a look at it, maybe you like it (or at least the idea of expanding data).

You can expand from min:max and by unique ids (which is convenient if you grouped by many variables, like date and gender), and you can select as many expandable columns as you wish.
It works great with the dplyr pipe and I use it a lot.

Feel free to contact me.