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
you can try this
library(data.table) setDT(dt) tmp <- dt[, .(date = seq.Date(min(date), max(date), by = '1 day')), by = 'user'] dt <- merge(tmp, dt, by = c('user', 'date'), all.x = TRUE) dt[, dummy := ifelse(is.na(dummy), 0, dummy)]