Imputing the dataset with Median
R
for (variable in colnames (dataset)) { dataset[[variable]][ is.na (dataset[[variable]])] <- median (dataset[[variable]], na.rm = TRUE ) } new_missing_values <- sum ( is.na (dataset)) cat ( "Missing values after imputation: " , new_missing_values) |
Output:
Missing values after imputation: 0
- Here, we first traversed through all the columns of dataset, then we imputed the missing values in that column with the median value of that respective feature
- At last, we are printing the number of N/A values after imputation which has to be 0.
The missing values have been handled successfully, now we can proceed further with the model.
Multiple linear regression analysis of Boston Housing Dataset using R
In this article, we are going to perform multiple linear regression analyses on the Boston Housing dataset using the R programming language.