This function imputes mean The function can impute mean for all columns or for a selected set of columns.
impute_mean(df, variables = colnames(df))
A data frame containing the data to impute.
A character vector containing the names of the columns to impute using mean. The default value is a list containing all column names of `df`.
A data frame with the same dimensions as `df` where missing values have been imputed using the mean.
df <- data.frame(x <- c(1, NA, 3, NA),y <- c(NA, 4, 6, 8))
impute_mean(df)
#> x....c.1..NA..3..NA. y....c.NA..4..6..8.
#> 1 1 6
#> 2 2 4
#> 3 3 6
#> 4 2 8