Learn R Programming

specmine (version 4.0.0)

impute_nas_value: Impute missing values with a constant

Description

Replace all `NA` values in `dataset$data` by a user-defined constant.

Usage

impute_nas_value(dataset, value)

Value

A dataset object with the same structure as the input, where all missing values in `dataset$data` have been replaced by `value`. Other components of the dataset are preserved unchanged.

Arguments

dataset

A dataset object to modify.

value

A numeric or character value used to replace missing entries.

Examples

Run this code
data <- matrix(
  c(1, NA, 3, 4),
  nrow = 2,
  dimnames = list(c("x1", "x2"), c("s1", "s2"))
)
dataset <- list(data = data)
impute_nas_value(dataset, 0)

Run the code above in your browser using DataLab