This function imputes missing values in alphanumeric columns of a data frame. If a column is numeric, missing values are imputed with the column mean. Otherwise, missing values are imputed with the column mode (most common value).

fix_missing_alphanumeric_values(df)

Arguments

df

A data frame with missing values.

Value

A data frame with imputed missing values.

Examples

df <- data.frame(w = c(7, 8, 180, 7), x = c("a", "b", "c", NA),
                 y = c(4, 5, -6, 4), z = c(7, 8, NA, 7))
fix_missing_alphanumeric_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 a  4 7.000000