I'd like to fill NAs with either forward or backward value filling with data.table in R. I saw a few posts explaining how to do it, but still have some trouble for multiple columns.
Say, I have a data table DT with three columns ("a", "b", "c")
I tried the following code but did not work
var.names <- c("a", "b", "c")
DT[, var.names := na.locf(list(var.names)), with = FALSE]
or
DT[, var.names, roll = TRUE, with = FALSE]