Impute the median value into a vector with missing values

impute_median(x)

# S3 method for default
impute_median(x)

# S3 method for factor
impute_median(x)

Arguments

x

vector

Value

vector with median values replaced

Examples

vec <- rnorm(10) vec[sample(1:10, 3)] <- NA impute_median(vec)
#> [1] -0.3795665 -0.5889187 1.4241911 -0.7945301 -0.3795665 -0.3795665 #> [7] -0.2165372 -0.3795665 1.0867538 -1.5802161