miss_data: Handle missing data in a data frame.

Description Usage Arguments Value Examples

View source: R/miss_data.R

Description

Impute missing values with the strategy (mean, median) selected by the user.

Usage

1
miss_data(x_train, x_test, strategy)

Arguments

x_train

The train set dataframe with missing values in it.

x_test

The test set DataFrame with missing values in it.

strategy

The imputation strategy as a string

Value

list containing the x_train and x_test dataframes without any missing values.

Examples

1
2
3
4
x_train <- data.frame('x' = c(400, NA, 330, NA), 'y' = c(24, NA, 30, 560))
x_test <- data.frame('x' = c(NA, 130, 240, NA), 'y' = c(NA, 300, 450, 100))
x_train_imputed <- miss_data(x_train, x_test, 'mean')[[1]]
x_test_imputed <- miss_data(x_train, x_test, 'mean')[[2]]

UBC-MDS/easymlr documentation built on March 22, 2021, 1:46 p.m.