powered by
ZeroIfNA(x) Impute(x, FUN = function(x) median(x, na.rm = TRUE))
median
replace
z <- c(8, NA, 9, NA, 3) ZeroIfNA(z) # [1] 8 0 9 0 3 Impute(z) # [1] 8 8 9 8 3
Run the code above in your browser using DataLab