Impute the mean value into a vector with missing values

impute_mean(x)

# S3 method for default
impute_mean(x)

# S3 method for factor
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.509078646 0.115911160 #> [6] 0.036688637 -0.252584949 0.036688637 0.985024011 0.036688637