R/replace_NA_with_y.R
replace_NA_with_y.Rd
This function replaces NA values in a specified column of a data frame with corresponding values from another specified column. The function works like the 'coalesce' function in SQL, but it is designed to handle data frames.
replace_NA_with_y(data, var_with_NA, var_to_fill_NA)
A data frame.
A variable name within the data frame that contains missing values.
A variable name within the data frame that contains values to replace the missing values in var_with_NA.
A data frame with the NA values in the var_with_NA variable replaced by the corresponding values in the var_to_fill_NA variable. The var_to_fill_NA variable is removed from the output.