may I know how to loop through the columns and use the data.table functions in R. Below is my code. Although I fulfilled all the condition (I believe so at least), there was an error. Thanks in advance.
> for (i in names(baby2.dt)) {
+ baby2.dt[is.na(i), .(.N, i := mean(baby2.dt$i, na.rm=TRUE))]
+ }
Error in `:=`(i, mean(baby2.dt$i, na.rm = TRUE)) :
Check that is.data.table(DT) == TRUE. Otherwise, := and `:=`(...) are defined for use in j, once only and in particular ways. See help(":=").
> is.data.table(baby2.dt)
[1] TRUE