ft_impute {fctutils}R Documentation

Impute Missing Values in Factor Vector

Description

Replaces NA values in a factor vector using specified imputation methods.

Usage

ft_impute(factor_vec, method = "mode")

Arguments

factor_vec

A factor vector with potential NA values.

method

The imputation method: 'mode', 'random', or a user-defined function.

Value

A factor vector with NA values imputed.

Author(s)

Kai Guo

Examples

# Example factor vector with NAs
factor_vec <- factor(c('apple', NA, 'banana', 'apple', NA))

# Impute using mode
ft_impute(factor_vec, method = 'mode')

# Impute using random selection
ft_impute(factor_vec, method = 'random')

[Package fctutils version 0.0.7 Index]