impute_mode: Helper function that calculates the mode of a vector with no...

Description Usage Arguments Value See Also Examples

Description

impute_mode returns a vector of values imputed from the mode(s) of x.

Usage

1
impute_mode(x, n = 1, tiebreaker = "random")

Arguments

x

A vector.

n

The number of values to impute. Only relevant when when there is not a unique mode.

tiebreaker

How to break "ties" if there is not a single unique mode. The default is "random", which samples randomly with replacement from the different modes.

Value

The output of impute_mode is a vector of imputed values of length n

See Also

Other imputers: impute_ecdf, impute_sample, impute

Examples

1
2
3
4
5
6
7
x <- c("mode", "mode", "other", NA, NA)

# Impute mode
x_impute <- impute(x, impute_mode)

# Compare
data.frame(x, x_impute)

derek-damron/transform documentation built on May 15, 2019, 3:57 a.m.