Can you write me a function in R that replaces all missing values of a vector with the mean of that vector?
mean_impute <- function(x) { x[is.na(x)] <- mean(x, na.rm = TRUE); x }