Learn R Programming

specmine (version 4.0.0)

impute_nas_mean: Impute missing values with mean

Description

Replace missing values in each variable by the mean of the observed values for that variable.

Usage

impute_nas_mean(dataset)

Value

A dataset object with the same structure as the input, where missing values in `dataset$data` have been replaced by the mean of the corresponding variable calculated with `na.rm = TRUE`.

Arguments

dataset

A dataset object to modify.

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_mean(dataset)

Run the code above in your browser using DataLab