dt_fill_NAs: Fill missing values in a data.frame or a data.table by...

Description Usage Arguments Value Examples

View source: R/utility_functions.R

Description

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 '<-'.

Usage

1
dt_fill_NAs(DT, column_names = NULL, val = 0)

Arguments

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.

Value

A data.table with missing values replace with val.

Examples

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)

deepjyot1991/zimplify documentation built on Dec. 19, 2021, 10:09 p.m.