title: Use of na.locf function (zoo package) with .SD in data.table
body: <p>I am trying to fill out all NA's excluding the first two NA's for cols 1 and 4 and three NA's for cols 2 and 3 with most recent non-NA value . Here is my data and code: </p>
  
  <pre><code>  hh&lt;-structure(list(ka = c(NA, NA, 2, NA, NA, 3, NA, NA, NA, NA), 
          kb = c(NA, NA, NA, 2, NA, NA, 3, NA, NA, NA), gc = c(NA, 
          NA, NA, 3, NA, NA, 6, NA, NA, NA), hc = c(NA, NA, 8, NA, 
          NA, NA, 4, NA, NA, NA)), .Names = c("ka", "kb", "gc", "hc"
      ), row.names = c(NA, -10L), class = "data.frame")
  
  
  library(zoo) #na.locf
  library(data.table)
  
  setDT(hh)[,`:=`(ka=c(NA,NA,na.locf(ka)),kb=c(NA,NA,NA,na.locf(kb)),gc=c(NA,NA,NA,na.locf(gc)),hc=c(NA,NA,na.locf(hc)))][]
      ka kb gc hc
   1: NA NA NA NA
   2: NA NA NA NA
   3:  2 NA NA  8
   4:  2  2  3  8
   5:  2  2  3  8
   6:  3  2  3  8
   7:  3  3  6  4
   8:  3  3  6  4
   9:  3  3  6  4
  10:  3  3  6  4
  </code></pre>
  
  <p>However, I am looking for use of <code>lapply</code> with <code>.SD</code> as I have more than two columns for each type.  Is this possible?</p>