I have a large data.table, with many missing values scattered throughout its ~200k rows and 200 columns. I would like to re code those NA values to zeros as efficiently as
To generalize to many columns you could use this approach (using previous sample data but adding a column):
z = data.table(x = sample(c(NA_integer_, 1), 2e7, TRUE), y = sample(c(NA_integer_, 1), 2e7, TRUE))
z[, names(z) := lapply(.SD, function(x) fifelse(is.na(x), 0, x))]
Didn't test for the speed though