Learn R Programming

specmine (version 4.0.0)

missingvalues_imputation: Missing values imputation

Description

Impute missing values in a dataset using different methods.

Usage

missingvalues_imputation(dataset, method = "value", value = 5e-04, k = 5)

Value

A dataset object with the same overall structure as the input, in which missing values in `dataset$data` have been imputed according to the selected method. The returned object preserves the dataset components and updates the description to record the imputation step.

Arguments

dataset

A dataset object to process.

method

Imputation method: `"value"`, `"mean"`, `"median"`, `"knn"`, or `"linapprox"`.

value

If `method = "value"`, the value used to replace missing entries.

k

If `method = "knn"`, the number of neighbors used for imputation.

Examples

Run this code
data <- matrix(
  c(1, NA, 3, 4, 5, NA),
  nrow = 2,
  dimnames = list(c("x1", "x2"), c("s1", "s2", "s3"))
)
dataset <- list(data = data, description = "toy dataset")
missingvalues_imputation(dataset, method = "value", value = 0)

Run the code above in your browser using DataLab