Skip to contents

Fills NA per column with the mean / median / most frequent observed value. numpy's mode takes the SMALLEST value among ties, which sort(unique(.)) reproduces here.

Usage

morie_geron_simple_imputer(X, strategy = "mean")

Arguments

X

Numeric vector or matrix, NA = missing.

strategy

"mean", "median", "mode" or "most_frequent".

Value

List with imputed, statistics, n_missing, missing_by_column.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_simple_imputer(V)
#> $imputed
#> [1] 1 2 3 4 5 6 7 8
#> 
#> $statistics
#> [1] 4.5
#> 
#> $n_missing
#> [1] 0
#> 
#> $missing_by_column
#> [1] 0
#> 
#> $strategy
#> [1] "mean"
#> 
#> $estimate
#> [1] 1 2 3 4 5 6 7 8
#> 
#> $n
#> [1] 8
#>