Is a specialized function which takes a variable and turns it into two new variables to be used in a prediction model.

  1. the variable for which missing values are imputed by the median for the given year.

  2. an indicator when the variable is missing

na_impute_median(data, var, year = 2014, year_column)

Arguments

data

The data frame.

var

The variable used to create new variables.

year

Year used for the median for imputation.

year_column

Column with year to use median on.

Value

New data frame in which missing values are filled.