Learn R Programming

emil (version 2.2.10)

pre_impute_df: Impute a data frame

Description

This function imputes each column of data frames univariately with different functions depending on their class.

Usage

pre_impute_df(data, class_fun = list(numeric = function(x) median(x, na.rm =
  TRUE), integer = function(x) median(x, na.rm = TRUE)),
  default_fun = function(x) mode(x, na.rm = TRUE, allow_multiple = FALSE))

Arguments

data

Pre-processed data set with features in a data frame.

class_fun

List of functions to use for imputating specific feature classes.

default_fun

Function to use for imputation features of classes not listed in class_fun.

na.rm

Whether to remove missing values.

Examples

Run this code
# NOT RUN {
x <- iris
x[sample(150, 3), 1] <- NA                                                                          
x[sample(150, 1), 3] <- NA
x[sample(150, 5), 5] <- NA
y <- gl(2, 75)
fold <- resample("holdout", y, nfold=1)[[1]]
data <- pre_split(x, y, fold) %>%
    pre_impute_df
# }

Run the code above in your browser using DataLab