R/na_operations.R
replace_na_by_type.Rd
This function allows user to replace NA values based on type of the variable. For example NA in character columns can be replaced by "", logical NA values as FALSE, integer NA values as 0L and so on. User need to give the list of the default values what he or she want to be used in replacing.
replace_na_by_type(x, na_replace_list)
replace_na_by_type | the list of default values for each type to be used |
---|
Other help functions:
get_classification_name()
,
get_na_vars()
,
get_var_types()
,
left_join_replace_na()
,
make_regex()
if (FALSE) { ## Give list of NA values na_replace_list <- list( "logical"=FALSE, "character"="", "integer"=0L, "double"=0.0, "numeric"=0, # "Date"=lubridate::dmy("01-01-1900") ) d <- left_join(sample_cohort,sample_regdata) d %>% mutate_all(replace_na_by_type,na_replace_list) }