insert rows between dates by group

前端 未结 6 1826
半阙折子戏
半阙折子戏 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:16

    Assuming your data is called df1, and you want to add dates between two days try this:

    library(dplyr)
    df2 <- seq.Date(as.Date("2015-01-03"), as.Date("2015-01-06"), by ="day")
    left_join(df2, df1)
    

    If you're simply trying to add a new record, I suggest using rbind.

    rbind()
    

提交回复
热议问题