Impute the mean value into a vector with missing values

impute_mean(x)

# S3 method for default
impute_mean(x)

Arguments

x

vector

Value

vector with mean values replaced

Examples

vec <- rnorm(10) vec[sample(1:10, 3)] <- NA impute_mean(vec)
#> [1] -0.008593142 -0.530161130 -0.561854135 0.075967119 0.115911160 #> [6] 0.784028017 -0.252584949 0.075967119 0.985024011 0.075967119