If one wants to fill in missing values of a variable based on previous/posterior non NA observation within a group, the data.table command is
setkey(DT,id,da
Here's a slightly faster and more compact way of doing it (version 1.9.3+):
DT[, filled4 := DT[!is.na(value)][DT, value, roll = T]]