I'm trying to replace NA
cells by some value but only in one column. I found another thread explaining how to proceed but I don't understand how it works.
is.na(dt)
returns a data table tracing the original dt
but replacing all the values by either TRUE
or FALSE
depending on whether the original cell is NA
. Now a datatable first parameters is supposed to accept a logical vector to select lines, not a whole datatable. And indeed dt[is.na(dt)]
returns an error but dt[is.na(dt)]=0
will replace all the NA
values with 0
. Why does adding an =0
suddenly makes this call work ? Is it a special feature or part of datatable design.