A function to fill missing values in numeric columns of a data frame with the mean of the column.

fix_missing_numeric_values(df)

Arguments

df

A data frame with missing values.

Value

A data frame with missing numeric values filled with the column mean.

Examples

df <- data.frame(w = c(7, 8, 180, 7), x = c("a", "b", "c", "d"),
                 y = c(4, 5, -6, 4), z = c(7, 8, NA, 7))
fix_missing_numeric_values(df)
#>     w x  y        z
#> 1   7 a  4 7.000000
#> 2   8 b  5 8.000000
#> 3 180 c -6 7.333333
#> 4   7 d  4 7.000000