insert rows between dates by group

前端 未结 6 1804
半阙折子戏
半阙折子戏 2021-02-10 02:42

I want to insert rows between two dates by group. My way of doing it is so complicated that I insert missing values by last observation carry forwards and then merge. I was wond

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-10 03:13

    The simplest way that I have found to do this is with the padr library.

    library(padr)
    dt_padded <- pad(dt, group = "user", by = "date") %>%
      replace_na(list(dummy=0))
    

提交回复
热议问题