Learn R Programming

MVN (version 6.1)

impute_missing: Impute Missing Values

Description

Replace NAs in numeric variables using simple methods or mice-based imputation.

Usage

impute_missing(
  data,
  method = c("mean", "median", "mice"),
  m = 5,
  seed = 123,
  ...
)

Value

A data frame with missing values imputed.

Arguments

data

A numeric matrix or data frame.

method

Character; one of "mean", "median", or "mice". Default: "mean".

m

Integer; number of multiple imputations when method = "mice". Default: 5.

seed

Integer; random seed for mice imputation. Default: 123.

...

Additional arguments passed to mice::mice when method = "mice".

Examples

Run this code
if (FALSE) {
df <- data.frame(x = c(1, NA, 3), y = c(4, 5, NA))
impute_missing(df, method = "mice")
}

Run the code above in your browser using DataLab