New R user here. I have a dataframe that looks like this:
│ │ uID │ day│ status │
├───┼─────┼────┼────────┤
│ │ A │ 5 │ 1 │
│ │ B │ 4 │ 1 │
│ │ C │ 9 │ 1 │
I want to add new rows to this table so that each uID has a row for all days from 1 to [[day]]. Additionally, for all days leading up to [[day]], each uID's status will be 0.
For example:
│ │ uID │ day │ status │
├───┼─────┼─────┼────────┤
│ │ A │ 1 │ 0 │
│ │ A │ 2 │ 0 │
│ │ A │ 3 │ 0 │
│ │ A │ 4 │ 0 │
│ │ A │ 5 │ 1 │
│ │ B │ 1 │ 0 │
│ │ B │ 2 │ 0 │
│ │ B │ 3 │ 0 │
│ │ B │ 4 │ 1 │
There's definitely an ugly way to do this with some for-loops, but I was wondering if there's a more graceful way to do it, with something like a groupby?
Thanks!