Description Usage Arguments Value Examples
View source: R/utility_functions.R
Intelligently fill missing values in a data.frame or a data.table in memory. If column names are not provided, missing values will be filled in for all the columns where data type of the column matches with the val argument's data type. Use with caution. Since data is modified in memory, no data is returned. Hence no need to specify assignment operator '<-'.
1 | dt_fill_NAs(DT, column_names = NULL, val = 0)
|
DT |
A data.table or a data.frame. A data.frame will be converted to a data.table. |
column_names |
A character vector of column names to fill missing values. If NULL which is default, missing values will be filled in for all the columns where data type of the column matches with the val argument's data type. |
val |
Value to replace the missing values. Default is 0. |
A data.table with missing values replace with val.
1 2 | dt_sample <- data.table::data.table(Col_1 = c("a", "b", NA), Col_2 = c(2, NA, 5))
dt_fill_NAs(DT = dt_sample, val = 0)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.