Learn R Programming

missRanger (version 2.1.1)

imputeUnivariate: Univariate Imputation

Description

Fills missing values of a vector, matrix or data frame by sampling with replacement from the non-missing values. For data frames, this sampling is done within column.

Usage

imputeUnivariate(x, v = NULL, seed = NULL)

Arguments

x

A vector, matrix or data frame.

v

A character vector of column names to impute (only relevant if x is a data frame). The default NULL imputes all columns.

seed

An integer seed.

Value

x with imputed values.

Examples

Run this code
# NOT RUN {
imputeUnivariate(c(NA, 0, 1, 0, 1))
imputeUnivariate(c("A", "A", NA))
imputeUnivariate(as.factor(c("A", "A", NA)))
head(imputeUnivariate(generateNA(iris)))
head(imputeUnivariate(generateNA(iris), v = "Species"))
head(imputeUnivariate(generateNA(iris), v = c("Species", "Petal.Length")))
# }

Run the code above in your browser using DataLab