且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

R按类别填充缺失的日期

更新时间:2023-01-30 12:28:27

我们也可以在这里使用 complete :

We can use complete here as well :

library(dplyr)
library(tidyr)

x %>%
  group_by(product) %>%
  complete(xdate = seq(min(xdate), max(xdate), by = "1 day"), fill = list(number = 0))