Fastest way to replace NAs in a large data.table

后端 未结 10 1038
走了就别回头了
走了就别回头了 2020-11-22 17:10

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

10条回答
  •  余生分开走
    2020-11-22 17:36

    Here's the simplest one I could come up with:

    dt[is.na(dt)] <- 0

    It's efficient and no need to write functions and other glue code.

提交回复
热议问题