imp.missing: Impute missing values

View source: R/MPMcore.R

imp.missingR Documentation

Impute missing values

Description

Wrapper for the imputeR function impute.

Usage

imp.missing(M, x = NULL, mode = NULL, ...)

Arguments

M

A matrix or data.frame containing missing values.

x

An optional vector that will be attached to M. This can be useful if data with missing values can be attached to a reference dataset.

mode

Either "cat" (cateorical variables) or "con" (continuous variables).

...

Currently ignored.

Value

A data.frame with imputed missing values.

Author(s)

Fernando Palluzzi fernando.palluzzi@gmail.com

Examples


# Sample 30 subjects from the morphonode simulated dataset
data <- mosaic::sample(mpm.us, 30, replace = FALSE, prob = NULL)[, 2:15]

# Entries with missing values
missing <- matrix(c(10.0, 6.3, 1, 0, 0, 0, 0, 1, NA, 2, NA, 2, 3, NA,
                     6.4, 2.1, 1, 0, 0, 0, 0, 1, NA, 2, NA, 1, 1, NA),
                  nrow = 2, byrow = TRUE)
colnames(missing) <- colnames(mpm.us[, 2:15])

# Defining categorical subset
data.cat <- data.frame(apply(mpm.us[, 2:15], 2, factor))

# Imputing missing values
data.cat <- imp.missing(data.cat, x = missing, mode = "cat")
print(tail(data.cat))


Morphonodepredictivemodel/morphonode documentation built on Feb. 15, 2023, 4:51 a.m.