library(data.table)
DT <- data.table(
id = c(1, 1, 1, 2),
year = c(1992, 1989, 1991, 1992),
value = c(4.1, 4.5, 3.3, 3.2)
)
fill_gap(DT, value, along_with = year, by = id)
library(lubridate)
DT[, date:= mdy(c("03/01/1992", "04/03/1992", "07/15/1992", "08/21/1992"))]
DT[, datem := as.monthly(date)]
fill_gap(DT, value, along_with = datem , by = id)
Run the code above in your browser using DataLab